blob: e96e56692fe02bb6d522c7978aafc4952cee64a0 [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
38 release_version=0
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 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
102 ./imagebuilder.py -f ../../helm-charts/examples/api-test-images.yaml
Zack Williamsdc6cf042018-05-14 13:00:57 -0700103 popd
104 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700105 }
106 }
107
108 stage('minikube') {
109 steps {
110 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
111 sh '''
Zack Williamsdc6cf042018-05-14 13:00:57 -0700112 export MINIKUBE_WANTUPDATENOTIFICATION=false
113 export MINIKUBE_WANTREPORTERRORPROMPT=false
114 export CHANGE_MINIKUBE_NONE_USER=true
115 export MINIKUBE_HOME=$HOME
116 mkdir -p $HOME/.kube || true
117 touch $HOME/.kube/config
118 export KUBECONFIG=$HOME/.kube/config
119 sudo -E /usr/bin/minikube start --vm-driver=none
Zack Williams84a193e2018-05-08 15:57:45 -0700120 '''
Zack Williams9815fd52018-05-15 16:42:00 -0700121 script {
122 timeout(3) {
123 waitUntil {
124 sleep 5
125 def kc_ret = sh script: "kubectl get po", returnStatus: true
126 return (kc_ret == 0);
127 }
128 }
129 }
Zack Williams84a193e2018-05-08 15:57:45 -0700130 }
131 }
132 }
133 }
134
135 stage('helm') {
136 steps {
Zack Williams9815fd52018-05-15 16:42:00 -0700137 sh '''
138 helm init
139 sleep 60
140 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
141 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700142 }
143 }
144
145 stage('xos') {
146 steps {
147 sh '''
Zack Williamsdc6cf042018-05-14 13:00:57 -0700148 pushd cord/helm-charts
149 helm dep up xos-core
Zack Williams4c143832018-05-16 14:19:29 -0700150 helm install -f examples/api-test-values.yaml xos-core -n xos-core
Zack Williams84a193e2018-05-08 15:57:45 -0700151 sleep 60
Zack Williams9815fd52018-05-15 16:42:00 -0700152 helm status xos-core
Zack Williamsdc6cf042018-05-14 13:00:57 -0700153 popd
Zack Williams84a193e2018-05-08 15:57:45 -0700154 '''
155 }
156 }
157
158 stage('test'){
159 steps {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700160 sh '''
161 helm test xos-core
Zack Williamsdc6cf042018-05-14 13:00:57 -0700162 mkdir -p ./RobotLogs;
163 cp /tmp/helm_test_xos_core_logs_*/* ./RobotLogs
164 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700165
Zack Williamsdc6cf042018-05-14 13:00:57 -0700166 step([$class: 'RobotPublisher',
167 disableArchiveOutput: false,
168 logFileName: 'RobotLogs/log*.html',
169 otherFiles: '',
170 outputFileName: 'RobotLogs/output*.xml',
171 outputPath: '.',
172 passThreshold: 100,
173 reportFileName: 'RobotLogs/report*.html',
174 unstableThreshold: 0]);
Zack Williams84a193e2018-05-08 15:57:45 -0700175 }
176 }
177 }
178
179 post {
180 always {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700181 sh '''
Zack Williams9815fd52018-05-15 16:42:00 -0700182 kubectl get pods --all-namespaces
183 helm list
184 kubectl logs xos-core-api-test
Zack Williamsdc6cf042018-05-14 13:00:57 -0700185 kubectl delete pod xos-core-api-test
186 helm delete --purge xos-core
Zack Williamsa834c342018-05-31 11:30:15 -0700187 minikube delete
Zack Williamsdc6cf042018-05-14 13:00:57 -0700188 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700189 deleteDir()
190 }
191 }
192}