blob: 4bee85ae2f40b9150c748793dd1b954af303dcd5 [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'
alshabib61509fb2016-09-09 02:43:20 -070053
alshabib7f3be8d2016-09-27 18:04:56 -070054 stage 'Power cycle compute nodes'
55 parallel(
56 compute_1: {
57 sh "ipmitool -U admin -P admin -H 10.90.0.10 power cycle"
58 }, compute_2: {
59 sh "ipmitool -U admin -P admin -H 10.90.0.11 power cycle"
60 }, failfast : true
61 )
62
63 stage 'Wait for compute nodes to get deployed'
64 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')
65 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'
66 timeout(time: 30) {
67 waitUntil {
68 try {
69 num = sh(returnStdout: true, script: 'sshpass -p ${headnodepass} ssh -l ${headnodeuser} 10.90.0.251 maas pod-maas nodes list | grep Deployed')
70 return num == 2
71 } catch (exception) {
72 return false
73 }
74 }
75 }
76
alshabib152823c2016-09-07 23:49:12 -070077 currentBuild.result = 'SUCCESS'
alshabib81048bd2016-09-09 18:08:07 -070078 step([$class: 'Mailer', recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
alshabib152823c2016-09-07 23:49:12 -070079 } catch (err) {
80 currentBuild.result = 'FAILURE'
alshabib81048bd2016-09-09 18:08:07 -070081 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
alshabib152823c2016-09-07 23:49:12 -070082 } finally {
83 sh 'vagrant destroy -f corddev'
84 }
85 echo "RESULT: ${currentBuild.result}"
86 }
alshabib61509fb2016-09-09 02:43:20 -070087
alshabib152823c2016-09-07 23:49:12 -070088}