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 """ |
Zack Williams | c61b93a | 2018-06-28 11:59:47 -0700 | [diff] [blame] | 33 | #!/usr/bin/env bash |
| 34 | set -eu -o pipefail |
| 35 | |
| 36 | VERSIONFILE="" # file path to file containing version number |
| 37 | NEW_VERSION="" # version number found in VERSIONFILE |
Zack Williams | 2d0ac6b | 2018-06-29 09:17:41 -0700 | [diff] [blame] | 38 | releaseversion=0 |
Zack Williams | c61b93a | 2018-06-28 11:59:47 -0700 | [diff] [blame] | 39 | |
| 40 | function read_version { |
| 41 | if [ -f "VERSION" ] |
| 42 | then |
| 43 | NEW_VERSION=\$(head -n1 "VERSION") |
| 44 | VERSIONFILE="VERSION" |
| 45 | elif [ -f "package.json" ] |
| 46 | then |
| 47 | NEW_VERSION=\$(python -c 'import json,sys;obj=json.load(sys.stdin); print obj["version"]' < package.json) |
| 48 | VERSIONFILE="package.json" |
| 49 | else |
| 50 | echo "ERROR: No versioning file found!" |
| 51 | exit 1 |
| 52 | fi |
| 53 | } |
| 54 | |
| 55 | # check if the version is a released version |
| 56 | function check_if_releaseversion { |
| 57 | if [[ "\$NEW_VERSION" =~ ^([0-9]+)\\.([0-9]+)\\.([0-9]+)\$ ]] |
| 58 | then |
| 59 | echo "Version string '\$NEW_VERSION' in '\$VERSIONFILE' is a SemVer released version!" |
| 60 | releaseversion=1 |
| 61 | else |
| 62 | echo "Version string '\$NEW_VERSION' in '\$VERSIONFILE' is not a SemVer released version, skipping." |
| 63 | fi |
| 64 | } |
| 65 | |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 66 | pushd cord |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 67 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 68 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
Zack Williams | c61b93a | 2018-06-28 11:59:47 -0700 | [diff] [blame] | 69 | |
| 70 | pushd \$PROJECT_PATH |
| 71 | echo "Existing git tags:" |
| 72 | git tag -n |
| 73 | |
| 74 | read_version |
| 75 | check_if_releaseversion |
| 76 | |
| 77 | # perform checks if a released version |
| 78 | if [ "\$releaseversion" -eq "1" ] |
| 79 | then |
| 80 | git config --global user.email "apitest@opencord.org" |
| 81 | git config --global user.name "API Test" |
| 82 | |
| 83 | git tag -a "\$NEW_VERSION" -m "Tagged for api test on Gerrit patchset: ${gerritChangeNumber}" |
| 84 | |
| 85 | echo "Tags including new tag:" |
| 86 | git tag -n |
| 87 | |
| 88 | fi |
| 89 | popd |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 90 | popd |
| 91 | """ |
| 92 | } |
| 93 | } |
| 94 | |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 95 | stage('prep') { |
| 96 | parallel { |
| 97 | |
| 98 | stage('images') { |
| 99 | steps { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 100 | sh ''' |
Zack Williams | edb3b80 | 2018-05-25 17:39:03 -0700 | [diff] [blame] | 101 | pushd cord/automation-tools/developer |
Zack Williams | a318503 | 2018-07-03 17:38:33 -0700 | [diff] [blame] | 102 | mkdir ib_logs |
Zack Williams | 7fea572 | 2018-07-03 21:17:47 -0700 | [diff] [blame] | 103 | ./imagebuilder.py -l ib_logs -a ib_actions.yml -g ib_graph.dot -f ../../helm-charts/examples/api-test-images.yaml |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 104 | popd |
| 105 | ''' |
Zack Williams | a318503 | 2018-07-03 17:38:33 -0700 | [diff] [blame] | 106 | archiveArtifacts artifacts: 'cord/automation-tools/developer/ib_actions.yml, cord/automation-tools/developer/ib_graph.dot, cord/automation-tools/developer/ib_logs/*', fingerprint: true |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | |
| 110 | stage('minikube') { |
| 111 | steps { |
| 112 | /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */ |
| 113 | sh ''' |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 114 | export MINIKUBE_WANTUPDATENOTIFICATION=false |
| 115 | export MINIKUBE_WANTREPORTERRORPROMPT=false |
| 116 | export CHANGE_MINIKUBE_NONE_USER=true |
| 117 | export MINIKUBE_HOME=$HOME |
| 118 | mkdir -p $HOME/.kube || true |
| 119 | touch $HOME/.kube/config |
| 120 | export KUBECONFIG=$HOME/.kube/config |
| 121 | sudo -E /usr/bin/minikube start --vm-driver=none |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 122 | ''' |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 123 | script { |
| 124 | timeout(3) { |
| 125 | waitUntil { |
| 126 | sleep 5 |
| 127 | def kc_ret = sh script: "kubectl get po", returnStatus: true |
| 128 | return (kc_ret == 0); |
| 129 | } |
| 130 | } |
| 131 | } |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | stage('helm') { |
| 138 | steps { |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 139 | sh ''' |
| 140 | helm init |
| 141 | sleep 60 |
| 142 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 143 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
| 147 | stage('xos') { |
| 148 | steps { |
| 149 | sh ''' |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 150 | pushd cord/helm-charts |
| 151 | helm dep up xos-core |
Zack Williams | c4152f8 | 2018-07-03 17:12:29 -0700 | [diff] [blame] | 152 | helm install -f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml xos-core -n xos-core |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 153 | sleep 60 |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 154 | helm status xos-core |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 155 | popd |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 156 | ''' |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | stage('test'){ |
| 161 | steps { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 162 | sh ''' |
| 163 | helm test xos-core |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 164 | mkdir -p ./RobotLogs; |
| 165 | cp /tmp/helm_test_xos_core_logs_*/* ./RobotLogs |
| 166 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 167 | |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 168 | step([$class: 'RobotPublisher', |
| 169 | disableArchiveOutput: false, |
| 170 | logFileName: 'RobotLogs/log*.html', |
| 171 | otherFiles: '', |
| 172 | outputFileName: 'RobotLogs/output*.xml', |
| 173 | outputPath: '.', |
| 174 | passThreshold: 100, |
| 175 | reportFileName: 'RobotLogs/report*.html', |
| 176 | unstableThreshold: 0]); |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | post { |
| 182 | always { |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 183 | sh ''' |
Zack Williams | 9815fd5 | 2018-05-15 16:42:00 -0700 | [diff] [blame] | 184 | kubectl get pods --all-namespaces |
| 185 | helm list |
| 186 | kubectl logs xos-core-api-test |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 187 | kubectl delete pod xos-core-api-test |
| 188 | helm delete --purge xos-core |
Zack Williams | a834c34 | 2018-05-31 11:30:15 -0700 | [diff] [blame] | 189 | minikube delete |
Zack Williams | dc6cf04 | 2018-05-14 13:00:57 -0700 | [diff] [blame] | 190 | ''' |
Zack Williams | 84a193e | 2018-05-08 15:57:45 -0700 | [diff] [blame] | 191 | deleteDir() |
| 192 | } |
| 193 | } |
| 194 | } |