Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 1 | /* helm-api-test pipeline */ |
| 2 | |
| 3 | pipeline { |
| 4 | |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 5 | parameters { |
| 6 | string(name:'executorNode', defaultValue:'invalid', description:'Name of the Jenkins node to run the job on') |
| 7 | string(name:'manifestUrl', defaultValue:'invalid', description:'URL to the repo manifest') |
| 8 | string(name:'manifestBranch', defaultValue:'master', description:'Name of the repo branch to use') |
| 9 | } |
| 10 | |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 11 | /* no label, executor is determined by JJB */ |
| 12 | agent { |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 13 | label '${params.executorNode}' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | stages { |
| 17 | |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 18 | stage('checkout') { |
| 19 | steps { |
| 20 | checkout(changelog: false, \ |
| 21 | poll: false, |
| 22 | scm: [$class: 'RepoScm', \ |
| 23 | manifestRepositoryUrl: '${params.manifestUrl}', \ |
| 24 | manifestBranch: '${params.manifestBranch}', \ |
| 25 | currentBranch: true, \ |
| 26 | destinationDir: 'cord', \ |
| 27 | forceSync: true, |
| 28 | resetFirst: true, \ |
| 29 | quiet: true, \ |
| 30 | jobs: 4, \ |
| 31 | showAllChanges: true] \ |
| 32 | ) |
| 33 | } |
| 34 | } |
| 35 | |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 36 | stage('prep') { |
| 37 | parallel { |
| 38 | |
| 39 | stage('images') { |
| 40 | steps { |
| 41 | sh 'cd cord/build; ./scripts/imagebuilder.py -f helm-charts/examples/test-images.yaml' |
| 42 | |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | stage('minikube') { |
| 47 | steps { |
| 48 | /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */ |
| 49 | sh ''' |
| 50 | export MINIKUBE_WANTUPDATENOTIFICATION=false; |
| 51 | export MINIKUBE_WANTREPORTERRORPROMPT=false; |
| 52 | export CHANGE_MINIKUBE_NONE_USER=true; |
| 53 | export MINIKUBE_HOME=$HOME; |
| 54 | mkdir -p $HOME/.kube || true; |
| 55 | touch $HOME/.kube/config; |
| 56 | export KUBECONFIG=$HOME/.kube/config; |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 57 | minikube start --vm-driver=none; |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 58 | |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 59 | chown -R $USER $HOME/.minikube; |
| 60 | chgrp -R $(id -g) $HOME/.minikube; |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 61 | |
| 62 | for i in {1..150}; do # timeout for 5 minutes |
| 63 | ./kubectl get po &> /dev/null |
| 64 | if [ $? -ne 1 ]; then |
| 65 | break |
| 66 | fi |
| 67 | sleep 2 |
| 68 | done |
| 69 | ''' |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | stage('helm') { |
| 76 | steps { |
| 77 | sh 'helm init && sleep 60' |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | stage('xos') { |
| 82 | steps { |
| 83 | sh ''' |
| 84 | cd cord/build/helm-charts; |
| 85 | helm dep up xos-core; |
| 86 | helm install -f examples/test-values.yaml -f examples/candidate-tag-values.yaml xos-core -n xos-core; |
| 87 | sleep 60 |
| 88 | ''' |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | stage('test'){ |
| 93 | steps { |
| 94 | sh 'helm test xos-core' |
| 95 | sh 'kubectl logs xos-core-api-test' |
| 96 | } |
| 97 | post { |
| 98 | always { |
| 99 | archive '/tmp/helm_test_xos_core_logs_*/**' |
| 100 | |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | post { |
| 107 | always { |
| 108 | sh 'kubectl delete pod xos-core-api-test' |
| 109 | sh 'helm delete --purge xos-core' |
| 110 | deleteDir() |
| 111 | } |
| 112 | } |
| 113 | } |