From 3a4e2358a8b492d566eec8b38a57a696007eda2e Mon Sep 17 00:00:00 2001 From: Jacob LeGrone Date: Tue, 5 Jun 2018 20:41:54 -0400 Subject: [PATCH] feat(helmInstall): install helm charts --- vars/helmInstall.groovy | 19 +++++++++++++++++++ vars/helmInstall.txt | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 vars/helmInstall.groovy create mode 100644 vars/helmInstall.txt diff --git a/vars/helmInstall.groovy b/vars/helmInstall.groovy new file mode 100644 index 0000000..968b251 --- /dev/null +++ b/vars/helmInstall.groovy @@ -0,0 +1,19 @@ +#!/usr/bin/env groovy + +def call(Map config) { + List arguments = config.getOrDefault('args', []) + + if (config.values) { + arguments.add(0, "--values ${config.values}") + } + if (config.version) { + arguments.add("--version ${config.version}") + } + if (config.namespace) { + arguments.add("--namespace ${config.namespace}") + } else if (env.OC_PROJECT) { + arguments.add("--namespace ${env.OC_PROJECT}") + } + + sh "helm upgrade --install ${config.name} ${config.chart} --wait --force ${arguments.join(' ')}" +} diff --git a/vars/helmInstall.txt b/vars/helmInstall.txt new file mode 100644 index 0000000..7bc5ee0 --- /dev/null +++ b/vars/helmInstall.txt @@ -0,0 +1,36 @@ +Install a helm chart. + +
+
+ +Example Pipeline: + +
+  
+    // ./Jenkinsfile
+    pipeline {
+      agent { label 'default' }
+      stage('Install') {
+        steps {
+          helmInstall name: 'jenkins', // the helm release name
+                      namespace: 'myapp-build', // the namespace in which to install the release
+                      chart: 'stable/jenkins', // helm chart to install
+                      version: '0.16.1', // helm chart version
+                      values: 'overrides.yaml', // path to values override file
+                      args: ["--set rbac.serviceAccountName=jenkins"] // additional helm arguments
+        }
+      }
+    }
+  
+
+ +
+ +
+  
+    # ./overrides.yaml
+    Master:
+      Image: quay.io/jlegrone/jenkins
+      ImageTag: latest
+  
+