blob: 7ddfbe837f15b6453d1cde455305cb3a380dd39c [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
14 * STACK_DELETE Delete stack when finished (bool)
15 * STACK_REUSE Reuse stack (don't create one)
16 * STACK_CLEANUP_JOB Name of job for deleting Heat stack
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010017 *
18 * Expected parameters:
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010019 * required for STACK_TYPE=heat
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010020 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
21 * HEAT_STACK_ZONE Heat stack availability zone
22 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010023 * OPENSTACK_API_URL OpenStack API address
24 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
25 * OPENSTACK_API_PROJECT OpenStack project to connect to
26 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
27 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
28 *
29 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
30 *
31 * required for STACK_TYPE=NONE or empty string
32 * SALT_MASTER_URL URL of Salt-API
33
34 * K8S_API_SERVER Kubernetes API address
35 * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
36 *
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +040037 * TEMPEST_IMAGE_LINK Tempest image link
38 *
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030039 * optional parameters for overwriting soft params
40 * KUBERNETES_HYPERKUBE_IMAGE Docker repository and tag for hyperkube image
Matthew Mosesohnd00a8f52017-05-22 17:07:19 +030041 * CALICO_CNI_IMAGE Docker repository and tag for calico CNI image
42 * CALICO_NODE_IMAGE Docker repository and tag for calico node image
43 * CALICOCTL_IMAGE Docker repository and tag for calicoctl image
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030044 *
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010045 */
46
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020047common = new com.mirantis.mk.Common()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010048git = new com.mirantis.mk.Git()
49openstack = new com.mirantis.mk.Openstack()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020050orchestrate = new com.mirantis.mk.Orchestrate()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010051salt = new com.mirantis.mk.Salt()
Ondrej Smola8f35e482017-03-30 14:04:36 +020052test = new com.mirantis.mk.Test()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020053
Jakub Josef96ec3aa2017-05-29 17:53:56 +020054
Jakub Josef7f7bc8d2017-05-29 17:27:48 +020055
56
Tomáš Kukrálab2f3702017-05-11 09:17:43 +020057_MAX_PERMITTED_STACKS = 2
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030058overwriteFile = "/srv/salt/reclass/classes/cluster/overwrite.yml"
Tomáš Kukrále80680a2017-03-02 16:34:35 +010059
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010060timestamps {
61 node {
Jakub Josef96ec3aa2017-05-29 17:53:56 +020062 // try to get STACK_INSTALL or fallback to INSTALL if exists
63 try {
64 def temporary = STACK_INSTALL
65 } catch (MissingPropertyException e) {
66 try {
67 STACK_INSTALL = INSTALL
68 env['STACK_INSTALL'] = INSTALL
69 } catch (MissingPropertyException e2) {
70 common.errorMsg("Property STACK_INSTALL or INSTALL not found!")
71 }
72 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010073 try {
74 //
75 // Prepare machines
76 //
Tomáš Kukrála18de112017-03-02 13:57:47 +010077 stage ('Create infrastructure') {
Tomáš Kukrál6d627d62017-03-23 17:39:07 +010078
Tomáš Kukrála18de112017-03-02 13:57:47 +010079 if (STACK_TYPE == 'heat') {
80 // value defaults
81 def openstackCloud
82 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
83 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010084
Jakub Josef3c7915f2017-05-24 11:23:57 +020085 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
Filip Pytloun794ad952017-03-03 10:39:26 +010086 error("If you want to reuse existing stack you need to provide it's name")
87 }
88
Jakub Josef3c7915f2017-05-24 11:23:57 +020089 if (STACK_REUSE.toBoolean() == false) {
Filip Pytloun794ad952017-03-03 10:39:26 +010090 // Don't allow to set custom heat stack name
91 wrap([$class: 'BuildUser']) {
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010092 if (env.BUILD_USER_ID) {
Jakub Josef3c7915f2017-05-24 11:23:57 +020093 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010094 } else {
Jakub Josef3c7915f2017-05-24 11:23:57 +020095 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010096 }
Jakub Josef3c7915f2017-05-24 11:23:57 +020097 currentBuild.description = STACK_NAME
Filip Pytloun794ad952017-03-03 10:39:26 +010098 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010099 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100100
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100101 // set description
Jakub Josef3c7915f2017-05-24 11:23:57 +0200102 currentBuild.description = "${STACK_NAME}"
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100103
Tomáš Kukrála18de112017-03-02 13:57:47 +0100104 // get templates
Jakub Josef3c7915f2017-05-24 11:23:57 +0200105 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100106
107 // create openstack env
108 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
109 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
110 openstack.getKeystoneToken(openstackCloud, openstackEnv)
Jakub Josef458913d2017-05-10 15:37:56 +0200111 //
112 // Verify possibility of create stack for given user and stack type
113 //
114 wrap([$class: 'BuildUser']) {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200115 if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) {
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200116 def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
117 if(existingStacks.size() >= _MAX_PERMITTED_STACKS){
Jakub Josef3c7915f2017-05-24 11:23:57 +0200118 STACK_DELETE = "false"
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200119 throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
120 }
Jakub Josef458913d2017-05-10 15:37:56 +0200121 }
122 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100123 // launch stack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200124 if (STACK_REUSE.toBoolean() == false) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100125 stage('Launch new Heat stack') {
126 // create stack
127 envParams = [
128 'instance_zone': HEAT_STACK_ZONE,
129 'public_net': HEAT_STACK_PUBLIC_NET
130 ]
Jakub Josef3c7915f2017-05-24 11:23:57 +0200131 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100132 }
133 }
134
135 // get SALT_MASTER_URL
Jakub Josef3c7915f2017-05-24 11:23:57 +0200136 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv)
137 currentBuild.description = "${STACK_NAME}: ${saltMasterHost}"
Tomáš Kukrál615aa9c2017-03-04 15:29:08 +0100138
Ales Komarek47a29f12017-04-26 12:05:47 +0200139 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100140 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100141 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100142
Tomáš Kukrála18de112017-03-02 13:57:47 +0100143 //
144 // Connect to Salt master
145 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100146
Tomáš Kukrála18de112017-03-02 13:57:47 +0100147 def saltMaster
148 stage('Connect to Salt API') {
149 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
150 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100151
Tomáš Kukrála18de112017-03-02 13:57:47 +0100152 //
153 // Install
154 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100155
Jakub Josef3c7915f2017-05-24 11:23:57 +0200156 if (common.checkContains('STACK_INSTALL', 'core')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100157 stage('Install core infrastructure') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200158 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100159
Jakub Josef3c7915f2017-05-24 11:23:57 +0200160 if (common.checkContains('STACK_INSTALL', 'kvm')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200161 orchestrate.installInfraKvm(saltMaster)
162 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100163 }
164
Ales Komarek47a29f12017-04-26 12:05:47 +0200165 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100166 }
167 }
168
169 // install k8s
Jakub Josef3c7915f2017-05-24 11:23:57 +0200170 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100171 stage('Install Kubernetes infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200172 orchestrate.installKubernetesInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100173 }
174
Tomáš Kukrála18de112017-03-02 13:57:47 +0100175 stage('Install Kubernetes control') {
Tomáš Kukrál06c27a92017-03-01 16:21:46 +0100176
Ales Komarek47a29f12017-04-26 12:05:47 +0200177 // Overwrite Kubernetes vars if specified
178 if (env.getEnvironment().containsKey("KUBERNETES_HYPERKUBE_IMAGE")) {
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200179 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_hyperkube_image: ${KUBERNETES_HYPERKUBE_IMAGE}")
Ales Komarek47a29f12017-04-26 12:05:47 +0200180 }
Matthew Mosesohnd00a8f52017-05-22 17:07:19 +0300181 // Overwrite Calico vars if specified
182 if (env.getEnvironment().containsKey("CALICO_CNI_IMAGE")) {
183 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_calico_cni_image: ${CALICO_CNI_IMAGE}")
184 }
185 if (env.getEnvironment().containsKey("CALICO_NODE_IMAGE")) {
186 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_calico_node_image: ${CALICO_NODE_IMAGE}")
187 }
188 if (env.getEnvironment().containsKey("CALICOCTL_IMAGE")) {
189 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_calicoctl_image: ${CALICOCTL_IMAGE}")
190 }
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100191
Ales Komarek47a29f12017-04-26 12:05:47 +0200192 orchestrate.installKubernetesControl(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100193 }
Tomáš Kukrálfeb959e2017-05-18 11:00:41 +0200194
195
Jakub Josef3c7915f2017-05-24 11:23:57 +0200196 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Tomáš Kukrálfeb959e2017-05-18 11:00:41 +0200197 state('Install Contrail for Kubernetes') {
198 orchestrate.installContrailNetwork(saltMaster)
199 orchestrate.installContrailCompute(saltMaster)
200 }
201 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100202 }
203
Tomáš Kukrála18de112017-03-02 13:57:47 +0100204 // install openstack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200205 if (common.checkContains('STACK_INSTALL', 'openstack')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100206 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100207
Tomáš Kukrála18de112017-03-02 13:57:47 +0100208 stage('Install OpenStack infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200209 orchestrate.installOpenstackInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100210 }
211
Tomáš Kukrála18de112017-03-02 13:57:47 +0100212 stage('Install OpenStack control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200213 orchestrate.installOpenstackControl(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100214 }
215
216 stage('Install OpenStack network') {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100217
Jakub Josef3c7915f2017-05-24 11:23:57 +0200218 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200219 orchestrate.installContrailNetwork(saltMaster)
Jakub Josef3c7915f2017-05-24 11:23:57 +0200220 } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200221 orchestrate.installOpenstackNetwork(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100222 }
223
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200224 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
225 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100226 }
227
228 stage('Install OpenStack compute') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200229 orchestrate.installOpenstackCompute(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100230
Jakub Josef3c7915f2017-05-24 11:23:57 +0200231 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200232 orchestrate.installContrailCompute(saltMaster)
Tomáš Kukráld5a40af2017-03-07 15:34:58 +0100233 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100234 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100235
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100236 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100237
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100238
Jakub Josef3c7915f2017-05-24 11:23:57 +0200239 if (common.checkContains('STACK_INSTALL', 'stacklight')) {
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100240 stage('Install StackLight') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200241 orchestrate.installStacklightControl(saltMaster)
242 orchestrate.installStacklightClient(saltMaster)
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100243 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100244 }
245
Tomáš Kukrála18de112017-03-02 13:57:47 +0100246 //
247 // Test
248 //
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200249 def artifacts_dir = '_artifacts/'
Tomáš Kukrála18de112017-03-02 13:57:47 +0100250
Jakub Josef3c7915f2017-05-24 11:23:57 +0200251 if (common.checkContains('STACK_TEST', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100252 stage('Run k8s bootstrap tests') {
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200253 def image = 'tomkukral/k8s-scripts'
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200254 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200255
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200256 // run image
257 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200258
259 // collect output
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200260 sh "mkdir -p ${artifacts_dir}"
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200261 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200262 writeFile file: "${artifacts_dir}${output_file}", text: file_content
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200263 sh "cat ${artifacts_dir}${output_file}"
264
265 // collect artifacts
266 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
Tomáš Kukrála18de112017-03-02 13:57:47 +0100267 }
268
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200269 stage('Run k8s conformance e2e tests') {
270 //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
271
272 def image = K8S_CONFORMANCE_IMAGE
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200273 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200274
275 // run image
276 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
277
278 // collect output
279 sh "mkdir -p ${artifacts_dir}"
280 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
281 writeFile file: "${artifacts_dir}${output_file}", text: file_content
282 sh "cat ${artifacts_dir}${output_file}"
283
284 // collect artifacts
285 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
286 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100287 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100288
Jakub Josef3c7915f2017-05-24 11:23:57 +0200289 if (common.checkContains('STACK_TEST', 'openstack')) {
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400290 stage('Run OpenStack tests') {
291 test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK)
292 }
293
294 stage('Copy Tempest results to config node') {
295 test.copyTempestResults(saltMaster)
296 }
297 }
298
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100299 stage('Finalize') {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200300 if (STACK_INSTALL != '') {
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200301 try {
302 salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
303 } catch (Exception e) {
304 common.warningMsg('State apply failed but we should continue to run')
Jakub Josefa6904f12017-05-22 16:37:27 +0200305 throw e
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200306 }
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100307 }
308 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100309 } catch (Throwable e) {
310 currentBuild.result = 'FAILURE'
311 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100312 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100313
Tomáš Kukrál96b12d52017-03-07 22:43:37 +0100314
Tomáš Kukrála18de112017-03-02 13:57:47 +0100315 //
316 // Clean
317 //
318
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100319 if (STACK_TYPE == 'heat') {
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100320 // send notification
Jakub Josef3c7915f2017-05-24 11:23:57 +0200321 common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100322
Jakub Josef3c7915f2017-05-24 11:23:57 +0200323 if (STACK_DELETE.toBoolean() == true) {
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100324 common.errorMsg('Heat job cleanup triggered')
325 stage('Trigger cleanup job') {
Jakub Josef187bbba2017-05-24 18:16:00 +0200326 build job: STACK_CLEANUP_JOB, parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: STACK_NAME]]
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100327 }
328 } else {
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100329 if (currentBuild.result == 'FAILURE') {
330 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 +0100331
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100332 if (SALT_MASTER_URL) {
333 common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
334 }
Tomáš Kukrálb908dac2017-03-07 18:58:35 +0100335 }
336
Tomáš Kukrála18de112017-03-02 13:57:47 +0100337 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100338 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100339 }
340 }
341}