Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch heat/cloudformation stack |
| 4 | * |
| 5 | * Expected parameters: |
| 6 | * STACK_NAME Infrastructure stack name |
| 7 | * STACK_TEMPLATE Stack HOT/CFN template |
| 8 | * STACK_TYPE Deploy OpenStack/AWS [heat/aws] |
| 9 | * |
| 10 | * STACK_TEMPLATE_URL URL to git repo with stack templates |
| 11 | * STACK_TEMPLATE_CREDENTIALS Credentials to the templates repo |
| 12 | * STACK_TEMPLATE_BRANCH Stack templates repo branch |
| 13 | * |
| 14 | * STACK_DELETE Delete stack when finished (bool) |
| 15 | * STACK_REUSE Reuse existing stack (don't create one) |
| 16 | * STACK_INSTALL What should be installed (k8s, openstack, ...) |
| 17 | * STACK_TEST Run tests (bool) |
| 18 | * STACK_CLEANUP_JOB Name of job for deleting stack |
| 19 | * |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 20 | * STACK_COMPUTE_COUNT Number of compute nodes to launch |
| 21 | * |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 22 | * AWS_STACK_REGION CloudFormation AWS region |
| 23 | * AWS_API_CREDENTIALS AWS Access key ID with AWS secret access key |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 24 | * AWS_SSH_KEY AWS key pair name (used for SSH access) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 25 | * |
| 26 | * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters |
| 27 | * HEAT_STACK_ZONE Heat stack availability zone |
| 28 | * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool |
| 29 | * OPENSTACK_API_URL OpenStack API address |
| 30 | * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API |
| 31 | * OPENSTACK_API_PROJECT OpenStack project to connect to |
| 32 | * OPENSTACK_API_CLIENT Versions of OpenStack python clients |
| 33 | * OPENSTACK_API_VERSION Version of the OpenStack API (2/3) |
| 34 | * |
| 35 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 36 | * SALT_MASTER_URL URL of Salt master |
| 37 | * |
| 38 | * K8S_API_SERVER Kubernetes API address |
| 39 | * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 40 | * |
| 41 | * TEMPEST_IMAGE_LINK Tempest image link |
| 42 | * |
| 43 | */ |
| 44 | common = new com.mirantis.mk.Common() |
| 45 | git = new com.mirantis.mk.Git() |
| 46 | openstack = new com.mirantis.mk.Openstack() |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 47 | aws = new com.mirantis.mk.Aws() |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 48 | orchestrate = new com.mirantis.mk.Orchestrate() |
| 49 | salt = new com.mirantis.mk.Salt() |
| 50 | test = new com.mirantis.mk.Test() |
| 51 | |
| 52 | _MAX_PERMITTED_STACKS = 2 |
| 53 | overwriteFile = "/srv/salt/reclass/classes/cluster/override.yml" |
| 54 | |
Tomáš Kukrál | 31414a2 | 2017-06-09 14:17:53 +0200 | [diff] [blame] | 55 | def saltMaster |
Tomáš Kukrál | bc4be25 | 2017-06-06 11:28:40 +0200 | [diff] [blame] | 56 | |
Tomáš Kukrál | b19bdda | 2017-06-13 17:09:43 +0200 | [diff] [blame^] | 57 | if (STACK_TYPE == 'aws') { |
| 58 | def venv_path = 'aws_venv' |
| 59 | def env_vars = aws.getEnvVars(AWS_API_CREDENTIALS, AWS_STACK_REGION) |
| 60 | } |
| 61 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 62 | timestamps { |
| 63 | node { |
| 64 | try { |
| 65 | // |
| 66 | // Prepare machines |
| 67 | // |
| 68 | stage ('Create infrastructure') { |
| 69 | |
| 70 | if (STACK_TYPE == 'heat') { |
| 71 | // value defaults |
| 72 | def openstackCloud |
| 73 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
| 74 | def openstackEnv = "${env.WORKSPACE}/venv" |
| 75 | |
| 76 | if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') { |
| 77 | error("If you want to reuse existing stack you need to provide it's name") |
| 78 | } |
| 79 | |
| 80 | if (STACK_REUSE.toBoolean() == false) { |
| 81 | // Don't allow to set custom heat stack name |
| 82 | wrap([$class: 'BuildUser']) { |
| 83 | if (env.BUILD_USER_ID) { |
| 84 | STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
| 85 | } else { |
| 86 | STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
| 87 | } |
| 88 | currentBuild.description = STACK_NAME |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // set description |
| 93 | currentBuild.description = "${STACK_NAME}" |
| 94 | |
| 95 | // get templates |
| 96 | git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS) |
| 97 | |
| 98 | // create openstack env |
| 99 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
| 100 | openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT) |
| 101 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
| 102 | // |
| 103 | // Verify possibility of create stack for given user and stack type |
| 104 | // |
| 105 | wrap([$class: 'BuildUser']) { |
| 106 | if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) { |
| 107 | def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv) |
| 108 | if(existingStacks.size() >= _MAX_PERMITTED_STACKS){ |
| 109 | STACK_DELETE = "false" |
| 110 | throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}") |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | // launch stack |
| 115 | if (STACK_REUSE.toBoolean() == false) { |
| 116 | stage('Launch new Heat stack') { |
| 117 | // create stack |
| 118 | envParams = [ |
| 119 | 'instance_zone': HEAT_STACK_ZONE, |
| 120 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 121 | ] |
Ales Komarek | 5eb8b10 | 2017-05-24 14:00:22 +0200 | [diff] [blame] | 122 | openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
| 126 | // get SALT_MASTER_URL |
| 127 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv) |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 128 | currentBuild.description = "${STACK_NAME} ${saltMasterHost}" |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 129 | |
| 130 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 131 | } else if (STACK_TYPE == 'aws') { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 132 | |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 133 | |
| 134 | if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') { |
| 135 | error("If you want to reuse existing stack you need to provide it's name") |
| 136 | } |
| 137 | |
| 138 | if (STACK_REUSE.toBoolean() == false) { |
| 139 | // Don't allow to set custom stack name |
| 140 | wrap([$class: 'BuildUser']) { |
| 141 | if (env.BUILD_USER_ID) { |
| 142 | STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
| 143 | } else { |
| 144 | STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
| 145 | } |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 146 | } |
Tomáš Kukrál | dbf8ca8 | 2017-05-25 15:13:20 +0200 | [diff] [blame] | 147 | |
| 148 | // no underscore in STACK_NAME |
| 149 | STACK_NAME = STACK_NAME.replaceAll('_', '-') |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | // set description |
Tomáš Kukrál | dbf8ca8 | 2017-05-25 15:13:20 +0200 | [diff] [blame] | 153 | currentBuild.description = STACK_NAME |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 154 | |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 155 | if (STACK_REUSE.toBoolean() == false) { |
| 156 | // get templates |
| 157 | git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS) |
| 158 | |
| 159 | // setup environment |
| 160 | aws.setupVirtualEnv(venv_path) |
| 161 | |
| 162 | // start stack |
Tomáš Kukrál | ad79d32 | 2017-06-05 15:40:14 +0200 | [diff] [blame] | 163 | def stack_params = [ |
| 164 | "ParameterKey=KeyName,ParameterValue=" + AWS_SSH_KEY, |
| 165 | "ParameterKey=CmpNodeCount,ParameterValue=" + STACK_COMPUTE_COUNT |
| 166 | ] |
Tomáš Kukrál | dbb5840 | 2017-06-02 07:08:53 +0200 | [diff] [blame] | 167 | def template_file = 'cfn/' + STACK_TEMPLATE + '.yml' |
Tomáš Kukrál | d4c0fed | 2017-06-01 17:20:11 +0200 | [diff] [blame] | 168 | aws.createStack(venv_path, env_vars, template_file, STACK_NAME, stack_params) |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | // wait for stack to be ready |
| 172 | aws.waitForStatus(venv_path, env_vars, STACK_NAME, 'CREATE_COMPLETE') |
| 173 | |
| 174 | // get outputs |
| 175 | saltMasterHost = aws.getOutputs(venv_path, env_vars, STACK_NAME, 'SaltMasterIP') |
| 176 | currentBuild.description = "${STACK_NAME} ${saltMasterHost}" |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 177 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 178 | |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 179 | } else { |
| 180 | throw new Exception("STACK_TYPE ${STACK_TYPE} is not supported") |
| 181 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 182 | |
Tomáš Kukrál | 2070764 | 2017-06-09 13:35:13 +0200 | [diff] [blame] | 183 | // Connect to Salt master |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 184 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 185 | } |
| 186 | |
| 187 | // |
| 188 | // Install |
| 189 | // |
| 190 | |
| 191 | if (common.checkContains('STACK_INSTALL', 'core')) { |
| 192 | stage('Install core infrastructure') { |
| 193 | orchestrate.installFoundationInfra(saltMaster) |
| 194 | |
| 195 | if (common.checkContains('STACK_INSTALL', 'kvm')) { |
| 196 | orchestrate.installInfraKvm(saltMaster) |
| 197 | orchestrate.installFoundationInfra(saltMaster) |
| 198 | } |
| 199 | |
| 200 | orchestrate.validateFoundationInfra(saltMaster) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // install k8s |
| 205 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 206 | stage('Install Kubernetes infra') { |
Tomáš Kukrál | b19bdda | 2017-06-13 17:09:43 +0200 | [diff] [blame^] | 207 | // configure kubernetes_control_address - save loadbalancer |
| 208 | def kubernetes_control_address = aws.getOutputs(venv_path, env_vars, STACK_NAME, 'ControlLoadBalancer') |
| 209 | print(kubernetes_control_address) |
| 210 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', 'kubernetes_control_address', kubernetes_control_address) |
| 211 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 212 | orchestrate.installKubernetesInfra(saltMaster) |
| 213 | } |
| 214 | |
| 215 | stage('Install Kubernetes control') { |
| 216 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 217 | orchestrate.installKubernetesControl(saltMaster) |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 218 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 219 | } |
| 220 | |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 221 | stage('Scale Kubernetes computes') { |
Tomáš Kukrál | b9a7d6f | 2017-06-07 14:05:31 +0200 | [diff] [blame] | 222 | if (STACK_COMPUTE_COUNT > 0) { |
| 223 | if (STACK_TYPE == 'aws') { |
Tomáš Kukrál | fa0c745 | 2017-06-06 11:44:11 +0200 | [diff] [blame] | 224 | |
Tomáš Kukrál | b9a7d6f | 2017-06-07 14:05:31 +0200 | [diff] [blame] | 225 | // get stack info |
| 226 | def scaling_group = aws.getOutputs(venv_path, env_vars, STACK_NAME, 'ComputesScalingGroup') |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 227 | |
Tomáš Kukrál | b9a7d6f | 2017-06-07 14:05:31 +0200 | [diff] [blame] | 228 | //update autoscaling group |
| 229 | aws.updateAutoscalingGroup(venv_path, env_vars, scaling_group, ["--desired-capacity " + STACK_COMPUTE_COUNT]) |
Tomáš Kukrál | 8130a56 | 2017-06-06 11:09:22 +0200 | [diff] [blame] | 230 | |
Tomáš Kukrál | b9a7d6f | 2017-06-07 14:05:31 +0200 | [diff] [blame] | 231 | // wait for computes to boot up |
Tomáš Kukrál | edc1d8d | 2017-06-09 13:44:13 +0200 | [diff] [blame] | 232 | aws.waitForAutoscalingInstances(venv_path, env_vars, scaling_group) |
Tomáš Kukrál | f31a591 | 2017-06-13 15:47:25 +0200 | [diff] [blame] | 233 | sleep(60) |
Tomáš Kukrál | b9a7d6f | 2017-06-07 14:05:31 +0200 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | orchestrate.installKubernetesCompute(saltMaster) |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 237 | } |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 238 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 239 | |
| 240 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
Tomáš Kukrál | 391df0d | 2017-06-13 10:37:02 +0200 | [diff] [blame] | 241 | stage('Install Contrail for Kubernetes') { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 242 | orchestrate.installContrailNetwork(saltMaster) |
| 243 | orchestrate.installContrailCompute(saltMaster) |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // install openstack |
| 249 | if (common.checkContains('STACK_INSTALL', 'openstack')) { |
| 250 | // install Infra and control, tests, ... |
| 251 | |
| 252 | stage('Install OpenStack infra') { |
| 253 | orchestrate.installOpenstackInfra(saltMaster) |
| 254 | } |
| 255 | |
| 256 | stage('Install OpenStack control') { |
| 257 | orchestrate.installOpenstackControl(saltMaster) |
| 258 | } |
| 259 | |
| 260 | stage('Install OpenStack network') { |
| 261 | |
| 262 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
| 263 | orchestrate.installContrailNetwork(saltMaster) |
| 264 | } else if (common.checkContains('STACK_INSTALL', 'ovs')) { |
| 265 | orchestrate.installOpenstackNetwork(saltMaster) |
| 266 | } |
| 267 | |
| 268 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list']) |
| 269 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list']) |
| 270 | } |
| 271 | |
| 272 | stage('Install OpenStack compute') { |
| 273 | orchestrate.installOpenstackCompute(saltMaster) |
| 274 | |
| 275 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
| 276 | orchestrate.installContrailCompute(saltMaster) |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | } |
| 281 | |
| 282 | |
| 283 | if (common.checkContains('STACK_INSTALL', 'stacklight')) { |
| 284 | stage('Install StackLight') { |
| 285 | orchestrate.installStacklightControl(saltMaster) |
| 286 | orchestrate.installStacklightClient(saltMaster) |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | // |
| 291 | // Test |
| 292 | // |
| 293 | def artifacts_dir = '_artifacts/' |
| 294 | |
| 295 | if (common.checkContains('STACK_TEST', 'k8s')) { |
| 296 | stage('Run k8s bootstrap tests') { |
| 297 | def image = 'tomkukral/k8s-scripts' |
| 298 | def output_file = image.replaceAll('/', '-') + '.output' |
| 299 | |
| 300 | // run image |
| 301 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
| 302 | |
| 303 | // collect output |
| 304 | sh "mkdir -p ${artifacts_dir}" |
| 305 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 306 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 307 | sh "cat ${artifacts_dir}${output_file}" |
| 308 | |
| 309 | // collect artifacts |
| 310 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 311 | } |
| 312 | |
| 313 | stage('Run k8s conformance e2e tests') { |
| 314 | //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE) |
| 315 | |
| 316 | def image = K8S_CONFORMANCE_IMAGE |
| 317 | def output_file = image.replaceAll('/', '-') + '.output' |
| 318 | |
| 319 | // run image |
| 320 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
| 321 | |
| 322 | // collect output |
| 323 | sh "mkdir -p ${artifacts_dir}" |
| 324 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 325 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 326 | sh "cat ${artifacts_dir}${output_file}" |
| 327 | |
| 328 | // collect artifacts |
| 329 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | if (common.checkContains('STACK_TEST', 'openstack')) { |
| 334 | stage('Run deployment tests') { |
| 335 | test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK) |
| 336 | } |
| 337 | |
| 338 | stage('Copy test results to config node') { |
| 339 | test.copyTempestResults(saltMaster) |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | stage('Finalize') { |
| 344 | if (STACK_INSTALL != '') { |
| 345 | try { |
| 346 | salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true) |
| 347 | } catch (Exception e) { |
| 348 | common.warningMsg('State apply failed but we should continue to run') |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } catch (Throwable e) { |
| 353 | currentBuild.result = 'FAILURE' |
| 354 | throw e |
| 355 | } finally { |
| 356 | |
| 357 | |
| 358 | // |
| 359 | // Clean |
| 360 | // |
| 361 | |
Tomáš Kukrál | 439c62e | 2017-06-02 11:42:36 +0200 | [diff] [blame] | 362 | if (STACK_NAME && STACK_NAME != '') { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 363 | // send notification |
| 364 | common.sendNotification(currentBuild.result, STACK_NAME, ["slack"]) |
Tomáš Kukrál | 439c62e | 2017-06-02 11:42:36 +0200 | [diff] [blame] | 365 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 366 | |
Tomáš Kukrál | 439c62e | 2017-06-02 11:42:36 +0200 | [diff] [blame] | 367 | if (STACK_DELETE.toBoolean() == true) { |
| 368 | stage('Trigger cleanup job') { |
| 369 | common.errorMsg('Stack cleanup job triggered') |
| 370 | build(job: STACK_CLEANUP_JOB, parameters: [ |
| 371 | [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME], |
| 372 | [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE] |
| 373 | ]) |
| 374 | } |
| 375 | } else { |
| 376 | if (currentBuild.result == 'FAILURE') { |
| 377 | common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.") |
| 378 | if (SALT_MASTER_URL) { |
| 379 | common.errorMsg("Salt master URL: ${SALT_MASTER_URL}") |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | } |