blob: 4e70930b63fc3e6a2b0d0fd3332ce844f13813a8 [file] [log] [blame]
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01001/**
2 *
3 * Launch heat stack with basic k8s
4 * Flow parameters:
Jakub Josef3c7915f2017-05-24 11:23:57 +02005 * STACK_NAME Heat stack name
6 * STACK_TYPE Orchestration engine: heat, ''
7 * STACK_INSTALL What should be installed (k8s, openstack, ...)
8 * STACK_TEST What should be tested (k8s, openstack, ...)
9 *
10 * STACK_TEMPLATE_URL URL to git repo with stack templates
11 * STACK_TEMPLATE_BRANCH Stack templates repo branch
12 * STACK_TEMPLATE_CREDENTIALS Credentials to the stack templates repo
13 * STACK_TEMPLATE Heat stack HOT template
Vasyl Saienkod3bbc502017-07-17 10:46:36 +030014 * STACK_RECLASS_ADDRESS Stack reclass address
15 * STACK_RECLASS_BRANCH Stack reclass repo branch
Jakub Josef3c7915f2017-05-24 11:23:57 +020016 * STACK_DELETE Delete stack when finished (bool)
17 * STACK_REUSE Reuse stack (don't create one)
18 * STACK_CLEANUP_JOB Name of job for deleting Heat stack
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010019 *
20 * Expected parameters:
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010021 * required for STACK_TYPE=heat
Matthew Mosesohn59fc6482017-06-01 18:53:10 +030022 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
23 * HEAT_STACK_ZONE Heat stack availability zone
24 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
25 * OPENSTACK_API_URL OpenStack API address
26 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
27 * OPENSTACK_API_PROJECT OpenStack project to connect to
28 * OPENSTACK_API_PROJECT_DOMAIN Domain for OpenStack project
29 * OPENSTACK_API_PROJECT_ID ID for OpenStack project
30 * OPENSTACK_API_USER_DOMAIN Domain for OpenStack user
31 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
32 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010033 *
34 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
35 *
36 * required for STACK_TYPE=NONE or empty string
37 * SALT_MASTER_URL URL of Salt-API
38
39 * K8S_API_SERVER Kubernetes API address
40 * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
41 *
Tatyana Leontovicha6c02912017-07-10 20:02:18 +030042 * TEMPEST_IMAGE Tempest image link
43 * TARGET_TEST_NODE Node to run tests
44 * DOCKER_INSTALL Install docker on the target if tue
45 * PATTERN If not false, run tests matched to pattern only
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +040046 *
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030047 * optional parameters for overwriting soft params
Matthew Mosesohn13933442017-07-04 21:20:08 +030048 * SALT_OVERRIDES YAML with overrides for Salt deployment
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030049 *
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010050 */
51
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020052common = new com.mirantis.mk.Common()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010053git = new com.mirantis.mk.Git()
54openstack = new com.mirantis.mk.Openstack()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020055orchestrate = new com.mirantis.mk.Orchestrate()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010056salt = new com.mirantis.mk.Salt()
Ondrej Smola8f35e482017-03-30 14:04:36 +020057test = new com.mirantis.mk.Test()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020058
Tomáš Kukrálab2f3702017-05-11 09:17:43 +020059_MAX_PERMITTED_STACKS = 2
Tomáš Kukrále80680a2017-03-02 16:34:35 +010060
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010061timestamps {
62 node {
Jakub Josef96ec3aa2017-05-29 17:53:56 +020063 // try to get STACK_INSTALL or fallback to INSTALL if exists
64 try {
65 def temporary = STACK_INSTALL
66 } catch (MissingPropertyException e) {
67 try {
68 STACK_INSTALL = INSTALL
69 env['STACK_INSTALL'] = INSTALL
70 } catch (MissingPropertyException e2) {
71 common.errorMsg("Property STACK_INSTALL or INSTALL not found!")
72 }
73 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010074 try {
75 //
76 // Prepare machines
77 //
Tomáš Kukrála18de112017-03-02 13:57:47 +010078 stage ('Create infrastructure') {
Tomáš Kukrál6d627d62017-03-23 17:39:07 +010079
Tomáš Kukrála18de112017-03-02 13:57:47 +010080 if (STACK_TYPE == 'heat') {
81 // value defaults
82 def openstackCloud
83 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
84 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010085
Jakub Josef3c7915f2017-05-24 11:23:57 +020086 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
Filip Pytloun794ad952017-03-03 10:39:26 +010087 error("If you want to reuse existing stack you need to provide it's name")
88 }
89
Jakub Josef3c7915f2017-05-24 11:23:57 +020090 if (STACK_REUSE.toBoolean() == false) {
Filip Pytloun794ad952017-03-03 10:39:26 +010091 // Don't allow to set custom heat stack name
92 wrap([$class: 'BuildUser']) {
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010093 if (env.BUILD_USER_ID) {
Jakub Josef3c7915f2017-05-24 11:23:57 +020094 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010095 } else {
Jakub Josef3c7915f2017-05-24 11:23:57 +020096 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010097 }
Jakub Josef3c7915f2017-05-24 11:23:57 +020098 currentBuild.description = STACK_NAME
Filip Pytloun794ad952017-03-03 10:39:26 +010099 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100100 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100101
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100102 // set description
Jakub Josef3c7915f2017-05-24 11:23:57 +0200103 currentBuild.description = "${STACK_NAME}"
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100104
Tomáš Kukrála18de112017-03-02 13:57:47 +0100105 // get templates
Jakub Josef3c7915f2017-05-24 11:23:57 +0200106 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100107
108 // create openstack env
109 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +0300110 openstackCloud = openstack.createOpenstackEnv(
111 OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS,
Matthew Mosesohn59fc6482017-06-01 18:53:10 +0300112 OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN,
113 OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN,
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +0300114 OPENSTACK_API_VERSION)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100115 openstack.getKeystoneToken(openstackCloud, openstackEnv)
Jakub Josef458913d2017-05-10 15:37:56 +0200116 //
117 // Verify possibility of create stack for given user and stack type
118 //
119 wrap([$class: 'BuildUser']) {
chnydaf23f46b2017-06-05 14:54:27 +0200120 if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !env.BUILD_USER_ID.equals("mceloud") && !STACK_REUSE.toBoolean()) {
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200121 def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
122 if(existingStacks.size() >= _MAX_PERMITTED_STACKS){
Jakub Josef3c7915f2017-05-24 11:23:57 +0200123 STACK_DELETE = "false"
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200124 throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
125 }
Jakub Josef458913d2017-05-10 15:37:56 +0200126 }
127 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100128 // launch stack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200129 if (STACK_REUSE.toBoolean() == false) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100130 stage('Launch new Heat stack') {
131 // create stack
132 envParams = [
133 'instance_zone': HEAT_STACK_ZONE,
134 'public_net': HEAT_STACK_PUBLIC_NET
135 ]
Vasyl Saienkod3bbc502017-07-17 10:46:36 +0300136 try {
137 envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH)
138 envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS)
139 } catch (MissingPropertyException e) {
140 common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.")
141 }
Jakub Josef3c7915f2017-05-24 11:23:57 +0200142 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100143 }
144 }
145
146 // get SALT_MASTER_URL
Jakub Josef3c7915f2017-05-24 11:23:57 +0200147 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv)
148 currentBuild.description = "${STACK_NAME}: ${saltMasterHost}"
Tomáš Kukrál615aa9c2017-03-04 15:29:08 +0100149
Ales Komarek47a29f12017-04-26 12:05:47 +0200150 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100151 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100152 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100153
Tomáš Kukrála18de112017-03-02 13:57:47 +0100154 //
155 // Connect to Salt master
156 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100157
Tomáš Kukrála18de112017-03-02 13:57:47 +0100158 def saltMaster
159 stage('Connect to Salt API') {
160 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
161 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100162
Tomáš Kukrála18de112017-03-02 13:57:47 +0100163 //
164 // Install
165 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100166
Jakub Josef3c7915f2017-05-24 11:23:57 +0200167 if (common.checkContains('STACK_INSTALL', 'core')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100168 stage('Install core infrastructure') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200169 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100170
Jakub Josef3c7915f2017-05-24 11:23:57 +0200171 if (common.checkContains('STACK_INSTALL', 'kvm')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200172 orchestrate.installInfraKvm(saltMaster)
173 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100174 }
175
Ales Komarek47a29f12017-04-26 12:05:47 +0200176 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100177 }
178 }
179
Matthew Mosesohn30afef92017-07-19 16:49:45 +0300180 // Set up override params
181 if (env.getEnvironment().containsKey('SALT_OVERRIDES')) {
182 stage('Set Salt overrides') {
183 salt.setSaltOverrides(saltMaster, SALT_OVERRIDES)
184 }
185 }
186
Tomáš Kukrála18de112017-03-02 13:57:47 +0100187 // install k8s
Jakub Josef3c7915f2017-05-24 11:23:57 +0200188 if (common.checkContains('STACK_INSTALL', 'k8s')) {
vrovachev48ea8622017-06-28 10:28:56 +0400189
vrovachev7be1e962017-07-05 13:28:26 +0400190 // install infra libs for k8s
191 stage('Install Kubernetes infra') {
192 orchestrate.installKubernetesInfra(saltMaster)
193 }
194
vrovachev48ea8622017-06-28 10:28:56 +0400195 // If k8s install with contrail network manager then contrail need to be install first
196 if (common.checkContains('STACK_INSTALL', 'contrail')) {
197 stage('Install Contrail for Kubernetes') {
198 orchestrate.installContrailNetwork(saltMaster)
199 orchestrate.installContrailCompute(saltMaster)
200 orchestrate.installKubernetesContrailCompute(saltMaster)
201 }
202 }
203
Tomáš Kukrála18de112017-03-02 13:57:47 +0100204 stage('Install Kubernetes control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200205 orchestrate.installKubernetesControl(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100206 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100207 }
208
Tomáš Kukrála18de112017-03-02 13:57:47 +0100209 // install openstack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200210 if (common.checkContains('STACK_INSTALL', 'openstack')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100211 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100212
Tomáš Kukrála18de112017-03-02 13:57:47 +0100213 stage('Install OpenStack infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200214 orchestrate.installOpenstackInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100215 }
216
Tomáš Kukrála18de112017-03-02 13:57:47 +0100217 stage('Install OpenStack control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200218 orchestrate.installOpenstackControl(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100219 }
220
221 stage('Install OpenStack network') {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100222
Jakub Josef3c7915f2017-05-24 11:23:57 +0200223 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200224 orchestrate.installContrailNetwork(saltMaster)
Jakub Josef3c7915f2017-05-24 11:23:57 +0200225 } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200226 orchestrate.installOpenstackNetwork(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100227 }
228
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200229 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
230 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100231 }
232
Vasyl Saienko58ccaee2017-07-17 09:34:13 +0300233 if (salt.testTarget(saltMaster, 'I@ironic:conductor')){
234 stage('Install OpenStack Ironic conductor') {
235 orchestrate.installIronicConductor(saltMaster)
236 }
237 }
238
239
Tomáš Kukrála18de112017-03-02 13:57:47 +0100240 stage('Install OpenStack compute') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200241 orchestrate.installOpenstackCompute(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100242
Jakub Josef3c7915f2017-05-24 11:23:57 +0200243 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200244 orchestrate.installContrailCompute(saltMaster)
Tomáš Kukráld5a40af2017-03-07 15:34:58 +0100245 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100246 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100247
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100248 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100249
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100250
Martin Polreichbb6f5752017-06-30 12:37:41 +0200251 if (common.checkContains('STACK_INSTALL', 'sl-legacy')) {
252 stage('Install StackLight v1') {
253 orchestrate.installStacklightv1Control(saltMaster)
254 orchestrate.installStacklightv1Client(saltMaster)
255 }
256 }
257
Jakub Josef3c7915f2017-05-24 11:23:57 +0200258 if (common.checkContains('STACK_INSTALL', 'stacklight')) {
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100259 stage('Install StackLight') {
Martin Polreichbb6f5752017-06-30 12:37:41 +0200260 orchestrate.installDockerSwarm(saltMaster)
261 orchestrate.installStacklight(saltMaster)
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100262 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100263 }
264
Tomáš Kukrála18de112017-03-02 13:57:47 +0100265 //
266 // Test
267 //
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200268 def artifacts_dir = '_artifacts/'
Tomáš Kukrála18de112017-03-02 13:57:47 +0100269
Jakub Josef3c7915f2017-05-24 11:23:57 +0200270 if (common.checkContains('STACK_TEST', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100271 stage('Run k8s bootstrap tests') {
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200272 def image = 'tomkukral/k8s-scripts'
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200273 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200274
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200275 // run image
276 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200277
278 // collect output
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200279 sh "mkdir -p ${artifacts_dir}"
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200280 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200281 writeFile file: "${artifacts_dir}${output_file}", text: file_content
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200282 sh "cat ${artifacts_dir}${output_file}"
283
284 // collect artifacts
285 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
Tomáš Kukrála18de112017-03-02 13:57:47 +0100286 }
287
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200288 stage('Run k8s conformance e2e tests') {
289 //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
290
291 def image = K8S_CONFORMANCE_IMAGE
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200292 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200293
294 // run image
295 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
296
297 // collect output
298 sh "mkdir -p ${artifacts_dir}"
299 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
300 writeFile file: "${artifacts_dir}${output_file}", text: file_content
301 sh "cat ${artifacts_dir}${output_file}"
302
303 // collect artifacts
304 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
305 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100306 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100307
Jakub Josef3c7915f2017-05-24 11:23:57 +0200308 if (common.checkContains('STACK_TEST', 'openstack')) {
Tatyana Leontovicha6c02912017-07-10 20:02:18 +0300309 if (common.checkContains('DOCKER_INSTALL', 'true')) {
310 test.install_docker(saltMaster, TARGET)
311 }
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400312 stage('Run OpenStack tests') {
Tatyana Leontovicha6c02912017-07-10 20:02:18 +0300313 test.runTempestTests(saltMaster, TEMPEST_IMAGE, TARGET, PATTERN)
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400314 }
315
316 stage('Copy Tempest results to config node') {
Tatyana Leontovicha6c02912017-07-10 20:02:18 +0300317 test.copyTempestResults(saltMaster, TARGET)
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400318 }
319 }
320
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100321 stage('Finalize') {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200322 if (STACK_INSTALL != '') {
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200323 try {
324 salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
325 } catch (Exception e) {
326 common.warningMsg('State apply failed but we should continue to run')
Jakub Josefa6904f12017-05-22 16:37:27 +0200327 throw e
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200328 }
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100329 }
330 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100331 } catch (Throwable e) {
332 currentBuild.result = 'FAILURE'
333 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100334 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100335
Tomáš Kukrál96b12d52017-03-07 22:43:37 +0100336
Tomáš Kukrála18de112017-03-02 13:57:47 +0100337 //
338 // Clean
339 //
340
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100341 if (STACK_TYPE == 'heat') {
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100342 // send notification
Jakub Josef3c7915f2017-05-24 11:23:57 +0200343 common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100344
Jakub Josef3c7915f2017-05-24 11:23:57 +0200345 if (STACK_DELETE.toBoolean() == true) {
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100346 common.errorMsg('Heat job cleanup triggered')
347 stage('Trigger cleanup job') {
Tomáš Kukrálea079922017-06-22 09:12:15 +0200348 build(job: STACK_CLEANUP_JOB, parameters: [
349 [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME],
350 [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE],
351 [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL],
352 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS],
353 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT],
354 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN],
355 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID],
356 [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN],
357 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT],
358 [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION]
359 ])
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100360 }
361 } else {
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100362 if (currentBuild.result == 'FAILURE') {
363 common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.")
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100364
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100365 if (SALT_MASTER_URL) {
366 common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
367 }
Tomáš Kukrálb908dac2017-03-07 18:58:35 +0100368 }
369
Tomáš Kukrála18de112017-03-02 13:57:47 +0100370 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100371 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100372 }
373 }
374}