blob: 29887ded9c272b1eabbee4f43965d539f7896406 [file] [log] [blame]
alshabib152823c2016-09-07 23:49:12 -07001node ('build') {
alshabiba5d3a612016-09-09 11:02:05 -07002 stage 'Checkout cord repo'
3 checkout changelog: false, poll: false, scm: [$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', quiet: true]
alshabib152823c2016-09-07 23:49:12 -07004 dir('build') {
alshabibef069942016-09-09 17:08:36 -07005 stage 'Redeploy head node and Build Vagrant box'
alshabib152823c2016-09-07 23:49:12 -07006 try {
alshabib4e1c96e2016-09-28 16:26:24 -07007 parallel(
alshabibef069942016-09-09 17:08:36 -07008 maasOps: {
9 sh "maas login maas http://10.90.0.2/MAAS/api/2.0 ${apiKey}"
10 sh "maas maas machine release ${systemId}"
alshabib4e1c96e2016-09-28 16:26:24 -070011
alshabibef069942016-09-09 17:08:36 -070012 timeout(time: 15) {
13 waitUntil {
14 try {
15 sh "maas maas machine read ${systemId} | grep Ready"
16 return true
17 } catch (exception) {
18 return false
19 }
20 }
21 }
alshabib4e1c96e2016-09-28 16:26:24 -070022
alshabibef069942016-09-09 17:08:36 -070023 sh 'maas maas machines allocate'
24 sh "maas maas machine deploy ${systemId}"
alshabib4e1c96e2016-09-28 16:26:24 -070025
alshabibef069942016-09-09 17:08:36 -070026 timeout(time: 30) {
27 waitUntil {
28 try {
29 sh "maas maas machine read ${systemId} | grep Deployed"
30 return true
31 } catch (exception) {
32 return false
33 }
34 }
35 }
alshabib4e1c96e2016-09-28 16:26:24 -070036
alshabibef069942016-09-09 17:08:36 -070037 }, vagrantOps: {
38 sh 'vagrant up corddev'
39 }, failFast : true
40 )
alshabib4e1c96e2016-09-28 16:26:24 -070041
alshabibef069942016-09-09 17:08:36 -070042 stage 'Fetch CORD packages'
alshabib152823c2016-09-07 23:49:12 -070043 sh 'vagrant ssh -c "cd /cord/build; ./gradlew fetch" corddev'
alshabib4e1c96e2016-09-28 16:26:24 -070044
alshabibef069942016-09-09 17:08:36 -070045 stage 'Build CORD Images'
alshabib152823c2016-09-07 23:49:12 -070046 sh 'vagrant ssh -c "cd /cord/build; ./gradlew buildImages" corddev'
alshabib61509fb2016-09-09 02:43:20 -070047
alshabib152823c2016-09-07 23:49:12 -070048 stage 'Publish to headnode'
49 sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml publish" corddev'
alshabib61509fb2016-09-09 02:43:20 -070050
alshabib152823c2016-09-07 23:49:12 -070051 stage 'Deploy'
52 sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml deploy" corddev'
alshabib4e1c96e2016-09-28 16:26:24 -070053
alshabib7f3be8d2016-09-27 18:04:56 -070054 stage 'Power cycle compute nodes'
55 parallel(
56 compute_1: {
alshabib6bbce232016-09-27 21:53:06 -070057 sh 'ipmitool -U admin -P admin -H 10.90.0.10 power cycle'
alshabib7f3be8d2016-09-27 18:04:56 -070058 }, compute_2: {
alshabib6bbce232016-09-27 21:53:06 -070059 sh 'ipmitool -U admin -P admin -H 10.90.0.11 power cycle'
60 }, failFast : true
alshabib7f3be8d2016-09-27 18:04:56 -070061 )
62
63 stage 'Wait for compute nodes to get deployed'
alshabib6bbce232016-09-27 21:53:06 -070064 sh 'ssh-keygen -f "/home/ubuntu/.ssh/known_hosts" -R 10.90.0.251'
65 def cordapikey = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 sudo maas-region-admin apikey --username cord")
66 sh "sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 maas login pod-maas http://10.90.0.251/MAAS/api/1.0 $cordapikey"
alshabib4e1c96e2016-09-28 16:26:24 -070067 timeout(time: 45) {
alshabib7f3be8d2016-09-27 18:04:56 -070068 waitUntil {
69 try {
alshabib4e1c96e2016-09-28 16:26:24 -070070 num = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -l ${headnodeuser} 10.90.0.251 maas pod-maas nodes list | grep Deployed | wc -l").trim()
71 return num == '2'
72 } catch (exception) {
73 return false
74 }
75 }
76 }
77
78 stage 'Wait for computes nodes to be provisioned'
79 ip = sh (returnStdout: true, script:"sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 docker inspect --format '{{.NetworkSettings.Networks.maas_default.IPAddress}}' provisioner").trim()
80 timeout(time:45) {
81 waitUntil {
82 try {
alshabib0c9e6632016-09-28 21:37:15 -070083 out = sh (returnStdout: true, script:"sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 curl -sS http://$ip:4243/provision/ | jq -c '.[] | select(.status | contains(2))'").trim()
alshabib4e1c96e2016-09-28 16:26:24 -070084 return out != ""
alshabib7f3be8d2016-09-27 18:04:56 -070085 } catch (exception) {
86 return false
87 }
88 }
89 }
90
alshabib152823c2016-09-07 23:49:12 -070091 currentBuild.result = 'SUCCESS'
92 } catch (err) {
93 currentBuild.result = 'FAILURE'
alshabib81048bd2016-09-09 18:08:07 -070094 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
alshabib152823c2016-09-07 23:49:12 -070095 } finally {
96 sh 'vagrant destroy -f corddev'
97 }
98 echo "RESULT: ${currentBuild.result}"
99 }
alshabib61509fb2016-09-09 02:43:20 -0700100
alshabib152823c2016-09-07 23:49:12 -0700101}