blob: 164d4d2f6b74431e4d69413e8eaa9413a74d6d8f [file] [log] [blame]
Zack Williams84a193e2018-05-08 15:57:45 -07001/* helm-api-test pipeline */
2
3pipeline {
4
5 /* no label, executor is determined by JJB */
6 agent {
Zack Williamsdc6cf042018-05-14 13:00:57 -07007 label "${params.executorNode}"
Zack Williams84a193e2018-05-08 15:57:45 -07008 }
9
10 stages {
11
Zack Williamsdc6cf042018-05-14 13:00:57 -070012 stage('repo') {
Zack Williams90cf9fd2018-05-11 10:26:21 -070013 steps {
14 checkout(changelog: false, \
15 poll: false,
16 scm: [$class: 'RepoScm', \
Zack Williamsdc6cf042018-05-14 13:00:57 -070017 manifestRepositoryUrl: "${params.manifestUrl}", \
18 manifestBranch: "${params.manifestBranch}", \
Zack Williams90cf9fd2018-05-11 10:26:21 -070019 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 Williamsdc6cf042018-05-14 13:00:57 -070030 stage('patch') {
31 steps {
32 sh """
Zack Williamsc61b93a2018-06-28 11:59:47 -070033 #!/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 Williams2d0ac6b2018-06-29 09:17:41 -070038 releaseversion=0
Zack Williamsc61b93a2018-06-28 11:59:47 -070039
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 Williamsdc6cf042018-05-14 13:00:57 -070066 pushd cord
Zack Williams9815fd52018-05-15 16:42:00 -070067 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
Zack Williamsdc6cf042018-05-14 13:00:57 -070068 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
Zack Williamsc61b93a2018-06-28 11:59:47 -070069
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 Williamsdc6cf042018-05-14 13:00:57 -070090 popd
91 """
92 }
93 }
94
Zack Williams84a193e2018-05-08 15:57:45 -070095 stage('prep') {
96 parallel {
97
98 stage('images') {
99 steps {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700100 sh '''
Zack Williamsedb3b802018-05-25 17:39:03 -0700101 pushd cord/automation-tools/developer
Zack Williamsa3185032018-07-03 17:38:33 -0700102 mkdir ib_logs
Zack Williams7fea5722018-07-03 21:17:47 -0700103 ./imagebuilder.py -l ib_logs -a ib_actions.yml -g ib_graph.dot -f ../../helm-charts/examples/api-test-images.yaml
Zack Williamsdc6cf042018-05-14 13:00:57 -0700104 popd
105 '''
Zack Williamsa3185032018-07-03 17:38:33 -0700106 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 Williams84a193e2018-05-08 15:57:45 -0700107 }
108 }
109
110 stage('minikube') {
111 steps {
112 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
113 sh '''
Zack Williamsdc6cf042018-05-14 13:00:57 -0700114 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 Williams84a193e2018-05-08 15:57:45 -0700122 '''
Zack Williams9815fd52018-05-15 16:42:00 -0700123 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 Williams84a193e2018-05-08 15:57:45 -0700132 }
133 }
134 }
135 }
136
137 stage('helm') {
138 steps {
Zack Williams9815fd52018-05-15 16:42:00 -0700139 sh '''
140 helm init
141 sleep 60
142 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
143 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700144 }
145 }
146
147 stage('xos') {
148 steps {
149 sh '''
Zack Williamsdc6cf042018-05-14 13:00:57 -0700150 pushd cord/helm-charts
151 helm dep up xos-core
Zack Williamsc4152f82018-07-03 17:12:29 -0700152 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 Williams84a193e2018-05-08 15:57:45 -0700153 sleep 60
Zack Williams9815fd52018-05-15 16:42:00 -0700154 helm status xos-core
Zack Williamsdc6cf042018-05-14 13:00:57 -0700155 popd
Zack Williams84a193e2018-05-08 15:57:45 -0700156 '''
157 }
158 }
159
160 stage('test'){
161 steps {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700162 sh '''
163 helm test xos-core
Zack Williamsdc6cf042018-05-14 13:00:57 -0700164 mkdir -p ./RobotLogs;
165 cp /tmp/helm_test_xos_core_logs_*/* ./RobotLogs
166 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700167
Zack Williamsdc6cf042018-05-14 13:00:57 -0700168 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 Williams84a193e2018-05-08 15:57:45 -0700177 }
178 }
179 }
180
181 post {
182 always {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700183 sh '''
Zack Williams9815fd52018-05-15 16:42:00 -0700184 kubectl get pods --all-namespaces
185 helm list
186 kubectl logs xos-core-api-test
Zack Williamsdc6cf042018-05-14 13:00:57 -0700187 kubectl delete pod xos-core-api-test
188 helm delete --purge xos-core
Zack Williamsa834c342018-05-31 11:30:15 -0700189 minikube delete
Zack Williamsdc6cf042018-05-14 13:00:57 -0700190 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700191 deleteDir()
192 }
193 }
194}