blob: 11ddc84828fd359c088a8dc81e1f93a0653d124c [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 Mosesohn3f2e10a2017-05-24 17:25:37 +030044 * NETCHECKER_AGENT_IMAGE Docker repository and tag for netchecker agent image
45 * NETCHECKER_SERVER_IMAGE Docker repository and tag for netchecker server image
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030046 *
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010047 */
48
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020049common = new com.mirantis.mk.Common()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010050git = new com.mirantis.mk.Git()
51openstack = new com.mirantis.mk.Openstack()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020052orchestrate = new com.mirantis.mk.Orchestrate()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010053salt = new com.mirantis.mk.Salt()
Ondrej Smola8f35e482017-03-30 14:04:36 +020054test = new com.mirantis.mk.Test()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020055
Tomáš Kukrálab2f3702017-05-11 09:17:43 +020056_MAX_PERMITTED_STACKS = 2
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030057overwriteFile = "/srv/salt/reclass/classes/cluster/overwrite.yml"
Tomáš Kukrále80680a2017-03-02 16:34:35 +010058
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010059timestamps {
60 node {
Tomáš Kukrála18de112017-03-02 13:57:47 +010061 try {
62 //
63 // Prepare machines
64 //
Tomáš Kukrála18de112017-03-02 13:57:47 +010065 stage ('Create infrastructure') {
Tomáš Kukrál6d627d62017-03-23 17:39:07 +010066
Tomáš Kukrála18de112017-03-02 13:57:47 +010067 if (STACK_TYPE == 'heat') {
68 // value defaults
69 def openstackCloud
70 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
71 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010072
Jakub Josef3c7915f2017-05-24 11:23:57 +020073 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
Filip Pytloun794ad952017-03-03 10:39:26 +010074 error("If you want to reuse existing stack you need to provide it's name")
75 }
76
Jakub Josef3c7915f2017-05-24 11:23:57 +020077 if (STACK_REUSE.toBoolean() == false) {
Filip Pytloun794ad952017-03-03 10:39:26 +010078 // Don't allow to set custom heat stack name
79 wrap([$class: 'BuildUser']) {
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010080 if (env.BUILD_USER_ID) {
Jakub Josef3c7915f2017-05-24 11:23:57 +020081 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010082 } else {
Jakub Josef3c7915f2017-05-24 11:23:57 +020083 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010084 }
Jakub Josef3c7915f2017-05-24 11:23:57 +020085 currentBuild.description = STACK_NAME
Filip Pytloun794ad952017-03-03 10:39:26 +010086 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010087 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010088
Tomáš Kukrálcbabec42017-03-02 16:24:04 +010089 // set description
Jakub Josef3c7915f2017-05-24 11:23:57 +020090 currentBuild.description = "${STACK_NAME}"
Tomáš Kukrálcbabec42017-03-02 16:24:04 +010091
Tomáš Kukrála18de112017-03-02 13:57:47 +010092 // get templates
Jakub Josef3c7915f2017-05-24 11:23:57 +020093 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
Tomáš Kukrála18de112017-03-02 13:57:47 +010094
95 // create openstack env
96 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
97 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
98 openstack.getKeystoneToken(openstackCloud, openstackEnv)
Jakub Josef458913d2017-05-10 15:37:56 +020099 //
100 // Verify possibility of create stack for given user and stack type
101 //
102 wrap([$class: 'BuildUser']) {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200103 if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) {
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200104 def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
105 if(existingStacks.size() >= _MAX_PERMITTED_STACKS){
Jakub Josef3c7915f2017-05-24 11:23:57 +0200106 STACK_DELETE = "false"
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200107 throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
108 }
Jakub Josef458913d2017-05-10 15:37:56 +0200109 }
110 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100111 // launch stack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200112 if (STACK_REUSE.toBoolean() == false) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100113 stage('Launch new Heat stack') {
114 // create stack
115 envParams = [
116 'instance_zone': HEAT_STACK_ZONE,
117 'public_net': HEAT_STACK_PUBLIC_NET
118 ]
Jakub Josef3c7915f2017-05-24 11:23:57 +0200119 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100120 }
121 }
122
123 // get SALT_MASTER_URL
Jakub Josef3c7915f2017-05-24 11:23:57 +0200124 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv)
125 currentBuild.description = "${STACK_NAME}: ${saltMasterHost}"
Tomáš Kukrál615aa9c2017-03-04 15:29:08 +0100126
Ales Komarek47a29f12017-04-26 12:05:47 +0200127 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100128 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100129 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100130
Tomáš Kukrála18de112017-03-02 13:57:47 +0100131 //
132 // Connect to Salt master
133 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100134
Tomáš Kukrála18de112017-03-02 13:57:47 +0100135 def saltMaster
136 stage('Connect to Salt API') {
137 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
138 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100139
Tomáš Kukrála18de112017-03-02 13:57:47 +0100140 //
141 // Install
142 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100143
Jakub Josef3c7915f2017-05-24 11:23:57 +0200144 if (common.checkContains('STACK_INSTALL', 'core')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100145 stage('Install core infrastructure') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200146 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100147
Jakub Josef3c7915f2017-05-24 11:23:57 +0200148 if (common.checkContains('STACK_INSTALL', 'kvm')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200149 orchestrate.installInfraKvm(saltMaster)
150 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100151 }
152
Ales Komarek47a29f12017-04-26 12:05:47 +0200153 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100154 }
155 }
156
157 // install k8s
Jakub Josef3c7915f2017-05-24 11:23:57 +0200158 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100159 stage('Install Kubernetes infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200160 orchestrate.installKubernetesInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100161 }
162
Tomáš Kukrála18de112017-03-02 13:57:47 +0100163 stage('Install Kubernetes control') {
Tomáš Kukrál06c27a92017-03-01 16:21:46 +0100164
Ales Komarek47a29f12017-04-26 12:05:47 +0200165 // Overwrite Kubernetes vars if specified
166 if (env.getEnvironment().containsKey("KUBERNETES_HYPERKUBE_IMAGE")) {
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200167 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_hyperkube_image: ${KUBERNETES_HYPERKUBE_IMAGE}")
Ales Komarek47a29f12017-04-26 12:05:47 +0200168 }
Matthew Mosesohnd00a8f52017-05-22 17:07:19 +0300169 // Overwrite Calico vars if specified
170 if (env.getEnvironment().containsKey("CALICO_CNI_IMAGE")) {
171 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_calico_cni_image: ${CALICO_CNI_IMAGE}")
172 }
173 if (env.getEnvironment().containsKey("CALICO_NODE_IMAGE")) {
174 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_calico_node_image: ${CALICO_NODE_IMAGE}")
175 }
176 if (env.getEnvironment().containsKey("CALICOCTL_IMAGE")) {
177 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_calicoctl_image: ${CALICOCTL_IMAGE}")
178 }
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100179
Matthew Mosesohn3f2e10a2017-05-24 17:25:37 +0300180 // Overwrite netchecker vars if specified
181 if (env.getEnvironment().containsKey("NETCHECKER_AGENT_IMAGE")) {
182 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_netchecker_agent_image: ${NETCHECKER_AGENT_IMAGE}")
183 }
184 if (env.getEnvironment().containsKey("NETCHECKER_SERVER_IMAGE")) {
185 salt.runSaltProcessStep(saltmaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_netchecker_server_image: ${NETCHECKER_SERVER_IMAGE}")
186 }
187
188
Ales Komarek47a29f12017-04-26 12:05:47 +0200189 orchestrate.installKubernetesControl(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100190 }
Tomáš Kukrálfeb959e2017-05-18 11:00:41 +0200191
192
Jakub Josef3c7915f2017-05-24 11:23:57 +0200193 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Tomáš Kukrálfeb959e2017-05-18 11:00:41 +0200194 state('Install Contrail for Kubernetes') {
195 orchestrate.installContrailNetwork(saltMaster)
196 orchestrate.installContrailCompute(saltMaster)
197 }
198 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100199 }
200
Tomáš Kukrála18de112017-03-02 13:57:47 +0100201 // install openstack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200202 if (common.checkContains('STACK_INSTALL', 'openstack')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100203 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100204
Tomáš Kukrála18de112017-03-02 13:57:47 +0100205 stage('Install OpenStack infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200206 orchestrate.installOpenstackInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100207 }
208
Tomáš Kukrála18de112017-03-02 13:57:47 +0100209 stage('Install OpenStack control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200210 orchestrate.installOpenstackControl(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100211 }
212
213 stage('Install OpenStack network') {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100214
Jakub Josef3c7915f2017-05-24 11:23:57 +0200215 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200216 orchestrate.installContrailNetwork(saltMaster)
Jakub Josef3c7915f2017-05-24 11:23:57 +0200217 } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200218 orchestrate.installOpenstackNetwork(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100219 }
220
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200221 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
222 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100223 }
224
225 stage('Install OpenStack compute') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200226 orchestrate.installOpenstackCompute(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100227
Jakub Josef3c7915f2017-05-24 11:23:57 +0200228 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200229 orchestrate.installContrailCompute(saltMaster)
Tomáš Kukráld5a40af2017-03-07 15:34:58 +0100230 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100231 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100232
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100233 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100234
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100235
Jakub Josef3c7915f2017-05-24 11:23:57 +0200236 if (common.checkContains('STACK_INSTALL', 'stacklight')) {
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100237 stage('Install StackLight') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200238 orchestrate.installStacklightControl(saltMaster)
239 orchestrate.installStacklightClient(saltMaster)
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100240 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100241 }
242
Tomáš Kukrála18de112017-03-02 13:57:47 +0100243 //
244 // Test
245 //
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200246 def artifacts_dir = '_artifacts/'
Tomáš Kukrála18de112017-03-02 13:57:47 +0100247
Jakub Josef3c7915f2017-05-24 11:23:57 +0200248 if (common.checkContains('STACK_TEST', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100249 stage('Run k8s bootstrap tests') {
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200250 def image = 'tomkukral/k8s-scripts'
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200251 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200252
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200253 // run image
254 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200255
256 // collect output
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200257 sh "mkdir -p ${artifacts_dir}"
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200258 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200259 writeFile file: "${artifacts_dir}${output_file}", text: file_content
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200260 sh "cat ${artifacts_dir}${output_file}"
261
262 // collect artifacts
263 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
Tomáš Kukrála18de112017-03-02 13:57:47 +0100264 }
265
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200266 stage('Run k8s conformance e2e tests') {
267 //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
268
269 def image = K8S_CONFORMANCE_IMAGE
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200270 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200271
272 // run image
273 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
274
275 // collect output
276 sh "mkdir -p ${artifacts_dir}"
277 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
278 writeFile file: "${artifacts_dir}${output_file}", text: file_content
279 sh "cat ${artifacts_dir}${output_file}"
280
281 // collect artifacts
282 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
283 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100284 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100285
Jakub Josef3c7915f2017-05-24 11:23:57 +0200286 if (common.checkContains('STACK_TEST', 'openstack')) {
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400287 stage('Run OpenStack tests') {
288 test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK)
289 }
290
291 stage('Copy Tempest results to config node') {
292 test.copyTempestResults(saltMaster)
293 }
294 }
295
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100296 stage('Finalize') {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200297 if (STACK_INSTALL != '') {
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200298 try {
299 salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
300 } catch (Exception e) {
301 common.warningMsg('State apply failed but we should continue to run')
Jakub Josefa6904f12017-05-22 16:37:27 +0200302 throw e
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200303 }
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100304 }
305 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100306 } catch (Throwable e) {
307 currentBuild.result = 'FAILURE'
308 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100309 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100310
Tomáš Kukrál96b12d52017-03-07 22:43:37 +0100311
Tomáš Kukrála18de112017-03-02 13:57:47 +0100312 //
313 // Clean
314 //
315
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100316 if (STACK_TYPE == 'heat') {
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100317 // send notification
Jakub Josef3c7915f2017-05-24 11:23:57 +0200318 common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100319
Jakub Josef3c7915f2017-05-24 11:23:57 +0200320 if (STACK_DELETE.toBoolean() == true) {
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100321 common.errorMsg('Heat job cleanup triggered')
322 stage('Trigger cleanup job') {
Jakub Josef187bbba2017-05-24 18:16:00 +0200323 build job: STACK_CLEANUP_JOB, parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: STACK_NAME]]
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100324 }
325 } else {
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100326 if (currentBuild.result == 'FAILURE') {
327 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 +0100328
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100329 if (SALT_MASTER_URL) {
330 common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
331 }
Tomáš Kukrálb908dac2017-03-07 18:58:35 +0100332 }
333
Tomáš Kukrála18de112017-03-02 13:57:47 +0100334 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100335 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100336 }
337 }
338}