alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 1 | node ('build') { |
alshabib | a5d3a61 | 2016-09-09 11:02:05 -0700 | [diff] [blame] | 2 | stage 'Checkout cord repo' |
| 3 | checkout changelog: false, poll: false, scm: [$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', quiet: true] |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 4 | dir('build') { |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 5 | stage 'Redeploy head node and Build Vagrant box' |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 6 | try { |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 7 | 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 | ) |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 41 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 42 | stage 'Fetch CORD packages' |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 43 | sh 'vagrant ssh -c "cd /cord/build; ./gradlew fetch" corddev' |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 44 | |
| 45 | stage 'Build CORD Images' |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 46 | sh 'vagrant ssh -c "cd /cord/build; ./gradlew buildImages" corddev' |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 47 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 48 | 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' |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 50 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 51 | 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' |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 53 | |
alshabib | 7f3be8d | 2016-09-27 18:04:56 -0700 | [diff] [blame^] | 54 | 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 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 77 | currentBuild.result = 'SUCCESS' |
alshabib | 81048bd | 2016-09-09 18:08:07 -0700 | [diff] [blame] | 78 | step([$class: 'Mailer', recipients: 'cord-dev@opencord.org', sendToIndividuals: false]) |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 79 | } catch (err) { |
| 80 | currentBuild.result = 'FAILURE' |
alshabib | 81048bd | 2016-09-09 18:08:07 -0700 | [diff] [blame] | 81 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'cord-dev@opencord.org', sendToIndividuals: false]) |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 82 | } finally { |
| 83 | sh 'vagrant destroy -f corddev' |
| 84 | } |
| 85 | echo "RESULT: ${currentBuild.result}" |
| 86 | } |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 87 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 88 | } |