Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 1 | /* helm-api-test pipeline */ |
| 2 | |
| 3 | pipeline { |
| 4 | |
| 5 | /* no label, executor is determined by JJB */ |
| 6 | agent { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 7 | label "${params.executorNode}" |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | stages { |
| 11 | |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 12 | stage('repo') { |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 13 | steps { |
| 14 | checkout(changelog: false, \ |
| 15 | poll: false, |
| 16 | scm: [$class: 'RepoScm', \ |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 17 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 18 | manifestBranch: "${params.manifestBranch}", \ |
Zack Williams | 90cf9fd | 2018-05-11 10:26:21 -0700 | [diff] [blame] | 19 | currentBranch: true, \ |
| 20 | destinationDir: 'cord', \ |
| 21 | forceSync: true, |
| 22 | resetFirst: true, \ |
| 23 | quiet: true, \ |
| 24 | jobs: 4, \ |
| 25 | showAllChanges: true] \ |
| 26 | ) |
| 27 | } |
| 28 | } |
| 29 | |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 30 | stage('patch') { |
| 31 | steps { |
| 32 | sh """ |
| 33 | pushd cord |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 34 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 35 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 36 | popd |
| 37 | """ |
| 38 | } |
| 39 | } |
| 40 | |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 41 | stage('prep') { |
| 42 | parallel { |
| 43 | |
| 44 | stage('images') { |
| 45 | steps { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 46 | sh ''' |
Zack Williams | 07702f7 | 2018-05-22 16:12:23 -0700 | [diff] [blame] | 47 | pushd cord/automation-tools |
| 48 | ./developer/imagebuilder.py -f ../helm-charts/examples/api-test-images.yaml |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 49 | popd |
| 50 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | |
| 54 | stage('minikube') { |
| 55 | steps { |
| 56 | /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */ |
| 57 | sh ''' |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 58 | export MINIKUBE_WANTUPDATENOTIFICATION=false |
| 59 | export MINIKUBE_WANTREPORTERRORPROMPT=false |
| 60 | export CHANGE_MINIKUBE_NONE_USER=true |
| 61 | export MINIKUBE_HOME=$HOME |
| 62 | mkdir -p $HOME/.kube || true |
| 63 | touch $HOME/.kube/config |
| 64 | export KUBECONFIG=$HOME/.kube/config |
| 65 | sudo -E /usr/bin/minikube start --vm-driver=none |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 66 | ''' |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 67 | script { |
| 68 | timeout(3) { |
| 69 | waitUntil { |
| 70 | sleep 5 |
| 71 | def kc_ret = sh script: "kubectl get po", returnStatus: true |
| 72 | return (kc_ret == 0); |
| 73 | } |
| 74 | } |
| 75 | } |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | stage('helm') { |
| 82 | steps { |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 83 | sh ''' |
| 84 | helm init |
| 85 | sleep 60 |
| 86 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 87 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 88 | } |
| 89 | } |
| 90 | |
| 91 | stage('xos') { |
| 92 | steps { |
| 93 | sh ''' |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 94 | pushd cord/helm-charts |
| 95 | helm dep up xos-core |
Zack Williams | 4c14383 | 2018-05-16 14:19:29 -0700 | [diff] [blame] | 96 | helm install -f examples/api-test-values.yaml xos-core -n xos-core |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 97 | sleep 60 |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 98 | helm status xos-core |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 99 | popd |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 100 | ''' |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | stage('test'){ |
| 105 | steps { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 106 | sh ''' |
| 107 | helm test xos-core |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 108 | mkdir -p ./RobotLogs; |
| 109 | cp /tmp/helm_test_xos_core_logs_*/* ./RobotLogs |
| 110 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 111 | |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 112 | step([$class: 'RobotPublisher', |
| 113 | disableArchiveOutput: false, |
| 114 | logFileName: 'RobotLogs/log*.html', |
| 115 | otherFiles: '', |
| 116 | outputFileName: 'RobotLogs/output*.xml', |
| 117 | outputPath: '.', |
| 118 | passThreshold: 100, |
| 119 | reportFileName: 'RobotLogs/report*.html', |
| 120 | unstableThreshold: 0]); |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | post { |
| 126 | always { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 127 | sh ''' |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 128 | kubectl get pods --all-namespaces |
| 129 | helm list |
| 130 | kubectl logs xos-core-api-test |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 131 | kubectl delete pod xos-core-api-test |
| 132 | helm delete --purge xos-core |
| 133 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 134 | deleteDir() |
| 135 | } |
| 136 | } |
| 137 | } |