blob: 3223a1113b47c32b3551fd0d01151d9836f221d1 [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 {
alshabibef069942016-09-09 17:08:36 -07007 parallel(
8 maasOps: {
9 sh "maas login maas http://10.90.0.2/MAAS/api/2.0 ${apiKey}"
10 sh "maas maas machine release ${systemId}"
11
12 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 }
22
23 sh 'maas maas machines allocate'
24 sh "maas maas machine deploy ${systemId}"
25
26 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 }
36
37 }, vagrantOps: {
38 sh 'vagrant up corddev'
39 }, failFast : true
40 )
alshabib61509fb2016-09-09 02:43:20 -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'
alshabibef069942016-09-09 17:08:36 -070044
45 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'
alshabib6bbce232016-09-27 21:53:06 -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"
alshabib7f3be8d2016-09-27 18:04:56 -070067 timeout(time: 30) {
68 waitUntil {
69 try {
alshabib6bbce232016-09-27 21:53:06 -070070 num = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -l ${headnodeuser} 10.90.0.251 maas pod-maas nodes list | grep Deployed")
71 return num == "2"
alshabib7f3be8d2016-09-27 18:04:56 -070072 } catch (exception) {
73 return false
74 }
75 }
76 }
77
alshabib152823c2016-09-07 23:49:12 -070078 currentBuild.result = 'SUCCESS'
alshabib81048bd2016-09-09 18:08:07 -070079 step([$class: 'Mailer', recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
alshabib152823c2016-09-07 23:49:12 -070080 } catch (err) {
81 currentBuild.result = 'FAILURE'
alshabib81048bd2016-09-09 18:08:07 -070082 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
alshabib152823c2016-09-07 23:49:12 -070083 } finally {
84 sh 'vagrant destroy -f corddev'
85 }
86 echo "RESULT: ${currentBuild.result}"
87 }
alshabib61509fb2016-09-09 02:43:20 -070088
alshabib152823c2016-09-07 23:49:12 -070089}