blob: 7271d7a717b741b716fb6beff9a837e447b64c5d [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 """
33 pushd cord
Zack Williams9815fd52018-05-15 16:42:00 -070034 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
Zack Williamsdc6cf042018-05-14 13:00:57 -070035 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
36 popd
37 """
38 }
39 }
40
Zack Williams84a193e2018-05-08 15:57:45 -070041 stage('prep') {
42 parallel {
43
44 stage('images') {
45 steps {
Zack Williamsdc6cf042018-05-14 13:00:57 -070046 sh '''
Zack Williamsedb3b802018-05-25 17:39:03 -070047 pushd cord/automation-tools/developer
48 ./imagebuilder.py -f ../../helm-charts/examples/api-test-images.yaml
Zack Williamsdc6cf042018-05-14 13:00:57 -070049 popd
50 '''
Zack Williams84a193e2018-05-08 15:57:45 -070051 }
52 }
53
54 stage('minikube') {
55 steps {
56 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
57 sh '''
Zack Williamsdc6cf042018-05-14 13:00:57 -070058 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 Williams84a193e2018-05-08 15:57:45 -070066 '''
Zack Williams9815fd52018-05-15 16:42:00 -070067 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 Williams84a193e2018-05-08 15:57:45 -070076 }
77 }
78 }
79 }
80
81 stage('helm') {
82 steps {
Zack Williams9815fd52018-05-15 16:42:00 -070083 sh '''
84 helm init
85 sleep 60
86 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
87 '''
Zack Williams84a193e2018-05-08 15:57:45 -070088 }
89 }
90
91 stage('xos') {
92 steps {
93 sh '''
Zack Williamsdc6cf042018-05-14 13:00:57 -070094 pushd cord/helm-charts
95 helm dep up xos-core
Zack Williams4c143832018-05-16 14:19:29 -070096 helm install -f examples/api-test-values.yaml xos-core -n xos-core
Zack Williams84a193e2018-05-08 15:57:45 -070097 sleep 60
Zack Williams9815fd52018-05-15 16:42:00 -070098 helm status xos-core
Zack Williamsdc6cf042018-05-14 13:00:57 -070099 popd
Zack Williams84a193e2018-05-08 15:57:45 -0700100 '''
101 }
102 }
103
104 stage('test'){
105 steps {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700106 sh '''
107 helm test xos-core
Zack Williamsdc6cf042018-05-14 13:00:57 -0700108 mkdir -p ./RobotLogs;
109 cp /tmp/helm_test_xos_core_logs_*/* ./RobotLogs
110 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700111
Zack Williamsdc6cf042018-05-14 13:00:57 -0700112 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 Williams84a193e2018-05-08 15:57:45 -0700121 }
122 }
123 }
124
125 post {
126 always {
Zack Williamsdc6cf042018-05-14 13:00:57 -0700127 sh '''
Zack Williams9815fd52018-05-15 16:42:00 -0700128 kubectl get pods --all-namespaces
129 helm list
130 kubectl logs xos-core-api-test
Zack Williamsdc6cf042018-05-14 13:00:57 -0700131 kubectl delete pod xos-core-api-test
132 helm delete --purge xos-core
Zack Williamsa834c342018-05-31 11:30:15 -0700133 minikube delete
Zack Williamsdc6cf042018-05-14 13:00:57 -0700134 '''
Zack Williams84a193e2018-05-08 15:57:45 -0700135 deleteDir()
136 }
137 }
138}