blob: 9f4571c0a5ae8ca2298cba26310f4600c8ef0dd1 [file] [log] [blame]
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01001/**
Tomáš Kukrál4691f682017-07-27 16:36:12 +02002
3
4
5
6
7
8
9
10
11* This pipeline is deprecated, please use cloud-deploy-pipeline
12
13
14
15
16
17
18
19
20
21
22
23
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010024 *
25 * Launch heat stack with basic k8s
26 * Flow parameters:
Jakub Josef3c7915f2017-05-24 11:23:57 +020027 * STACK_NAME Heat stack name
28 * STACK_TYPE Orchestration engine: heat, ''
29 * STACK_INSTALL What should be installed (k8s, openstack, ...)
30 * STACK_TEST What should be tested (k8s, openstack, ...)
31 *
32 * STACK_TEMPLATE_URL URL to git repo with stack templates
33 * STACK_TEMPLATE_BRANCH Stack templates repo branch
34 * STACK_TEMPLATE_CREDENTIALS Credentials to the stack templates repo
35 * STACK_TEMPLATE Heat stack HOT template
Vasyl Saienkod3bbc502017-07-17 10:46:36 +030036 * STACK_RECLASS_ADDRESS Stack reclass address
37 * STACK_RECLASS_BRANCH Stack reclass repo branch
Jakub Josef3c7915f2017-05-24 11:23:57 +020038 * STACK_DELETE Delete stack when finished (bool)
39 * STACK_REUSE Reuse stack (don't create one)
40 * STACK_CLEANUP_JOB Name of job for deleting Heat stack
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010041 *
42 * Expected parameters:
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010043 * required for STACK_TYPE=heat
Matthew Mosesohn59fc6482017-06-01 18:53:10 +030044 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
45 * HEAT_STACK_ZONE Heat stack availability zone
46 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
47 * OPENSTACK_API_URL OpenStack API address
48 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
49 * OPENSTACK_API_PROJECT OpenStack project to connect to
50 * OPENSTACK_API_PROJECT_DOMAIN Domain for OpenStack project
51 * OPENSTACK_API_PROJECT_ID ID for OpenStack project
52 * OPENSTACK_API_USER_DOMAIN Domain for OpenStack user
53 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
54 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010055 *
56 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
57 *
58 * required for STACK_TYPE=NONE or empty string
59 * SALT_MASTER_URL URL of Salt-API
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010060 *
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +020061 * Test settings:
62 * TEST_K8S_API_SERVER Kubernetes API address
63 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
64 *
65 * TEST_TEMPEST_IMAGE Tempest image link
66 * TEST_DOCKER_INSTALL Install docker on the target if tue
67 * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only
68 * TEST_TEMPEST_TARGET Salt target for tempest node
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +040069 *
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030070 * optional parameters for overwriting soft params
Matthew Mosesohn13933442017-07-04 21:20:08 +030071 * SALT_OVERRIDES YAML with overrides for Salt deployment
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030072 *
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010073 */
74
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020075common = new com.mirantis.mk.Common()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010076git = new com.mirantis.mk.Git()
77openstack = new com.mirantis.mk.Openstack()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020078orchestrate = new com.mirantis.mk.Orchestrate()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010079salt = new com.mirantis.mk.Salt()
Ondrej Smola8f35e482017-03-30 14:04:36 +020080test = new com.mirantis.mk.Test()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020081
Tomáš Kukrálab2f3702017-05-11 09:17:43 +020082_MAX_PERMITTED_STACKS = 2
Tomáš Kukrále80680a2017-03-02 16:34:35 +010083
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010084timestamps {
85 node {
Jakub Josef96ec3aa2017-05-29 17:53:56 +020086 // try to get STACK_INSTALL or fallback to INSTALL if exists
87 try {
88 def temporary = STACK_INSTALL
89 } catch (MissingPropertyException e) {
90 try {
91 STACK_INSTALL = INSTALL
92 env['STACK_INSTALL'] = INSTALL
93 } catch (MissingPropertyException e2) {
94 common.errorMsg("Property STACK_INSTALL or INSTALL not found!")
95 }
96 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010097 try {
98 //
99 // Prepare machines
100 //
Tomáš Kukrála18de112017-03-02 13:57:47 +0100101 stage ('Create infrastructure') {
Tomáš Kukrál6d627d62017-03-23 17:39:07 +0100102
Tomáš Kukrála18de112017-03-02 13:57:47 +0100103 if (STACK_TYPE == 'heat') {
104 // value defaults
105 def openstackCloud
106 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
107 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100108
Jakub Josef3c7915f2017-05-24 11:23:57 +0200109 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
Filip Pytloun794ad952017-03-03 10:39:26 +0100110 error("If you want to reuse existing stack you need to provide it's name")
111 }
112
Jakub Josef3c7915f2017-05-24 11:23:57 +0200113 if (STACK_REUSE.toBoolean() == false) {
Filip Pytloun794ad952017-03-03 10:39:26 +0100114 // Don't allow to set custom heat stack name
115 wrap([$class: 'BuildUser']) {
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +0100116 if (env.BUILD_USER_ID) {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200117 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +0100118 } else {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200119 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +0100120 }
Jakub Josef3c7915f2017-05-24 11:23:57 +0200121 currentBuild.description = STACK_NAME
Filip Pytloun794ad952017-03-03 10:39:26 +0100122 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100123 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100124
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100125 // set description
Jakub Josef3c7915f2017-05-24 11:23:57 +0200126 currentBuild.description = "${STACK_NAME}"
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100127
Tomáš Kukrála18de112017-03-02 13:57:47 +0100128 // get templates
Jakub Josef3c7915f2017-05-24 11:23:57 +0200129 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100130
131 // create openstack env
132 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +0300133 openstackCloud = openstack.createOpenstackEnv(
134 OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS,
Matthew Mosesohn59fc6482017-06-01 18:53:10 +0300135 OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN,
136 OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN,
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +0300137 OPENSTACK_API_VERSION)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100138 openstack.getKeystoneToken(openstackCloud, openstackEnv)
Jakub Josef458913d2017-05-10 15:37:56 +0200139 //
140 // Verify possibility of create stack for given user and stack type
141 //
142 wrap([$class: 'BuildUser']) {
chnydaf23f46b2017-06-05 14:54:27 +0200143 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 +0200144 def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
145 if(existingStacks.size() >= _MAX_PERMITTED_STACKS){
Jakub Josef3c7915f2017-05-24 11:23:57 +0200146 STACK_DELETE = "false"
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200147 throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
148 }
Jakub Josef458913d2017-05-10 15:37:56 +0200149 }
150 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100151 // launch stack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200152 if (STACK_REUSE.toBoolean() == false) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100153 stage('Launch new Heat stack') {
154 // create stack
155 envParams = [
156 'instance_zone': HEAT_STACK_ZONE,
157 'public_net': HEAT_STACK_PUBLIC_NET
158 ]
Vasyl Saienkod3bbc502017-07-17 10:46:36 +0300159 try {
160 envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH)
161 envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS)
162 } catch (MissingPropertyException e) {
163 common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.")
164 }
Jakub Josef3c7915f2017-05-24 11:23:57 +0200165 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100166 }
167 }
168
169 // get SALT_MASTER_URL
Jakub Josef3c7915f2017-05-24 11:23:57 +0200170 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv)
171 currentBuild.description = "${STACK_NAME}: ${saltMasterHost}"
Tomáš Kukrál615aa9c2017-03-04 15:29:08 +0100172
Ales Komarek47a29f12017-04-26 12:05:47 +0200173 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100174 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100175 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100176
Tomáš Kukrála18de112017-03-02 13:57:47 +0100177 //
178 // Connect to Salt master
179 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100180
Tomáš Kukrála18de112017-03-02 13:57:47 +0100181 def saltMaster
182 stage('Connect to Salt API') {
183 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
184 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100185
Vasyl Saienko70fec662017-07-27 17:36:09 +0300186 // Set up override params
187 if (env.getEnvironment().containsKey('SALT_OVERRIDES')) {
188 stage('Set Salt overrides') {
189 salt.setSaltOverrides(saltMaster, SALT_OVERRIDES)
190 }
191 }
192
Tomáš Kukrála18de112017-03-02 13:57:47 +0100193 //
194 // Install
195 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100196
Jakub Josef3c7915f2017-05-24 11:23:57 +0200197 if (common.checkContains('STACK_INSTALL', 'core')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100198 stage('Install core infrastructure') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200199 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100200
Jakub Josef3c7915f2017-05-24 11:23:57 +0200201 if (common.checkContains('STACK_INSTALL', 'kvm')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200202 orchestrate.installInfraKvm(saltMaster)
203 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100204 }
205
Ales Komarek47a29f12017-04-26 12:05:47 +0200206 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100207 }
208 }
209
210 // install k8s
Jakub Josef3c7915f2017-05-24 11:23:57 +0200211 if (common.checkContains('STACK_INSTALL', 'k8s')) {
vrovachev48ea8622017-06-28 10:28:56 +0400212
vrovachev7be1e962017-07-05 13:28:26 +0400213 // install infra libs for k8s
214 stage('Install Kubernetes infra') {
215 orchestrate.installKubernetesInfra(saltMaster)
216 }
217
vrovachev48ea8622017-06-28 10:28:56 +0400218 // If k8s install with contrail network manager then contrail need to be install first
219 if (common.checkContains('STACK_INSTALL', 'contrail')) {
220 stage('Install Contrail for Kubernetes') {
221 orchestrate.installContrailNetwork(saltMaster)
222 orchestrate.installContrailCompute(saltMaster)
223 orchestrate.installKubernetesContrailCompute(saltMaster)
224 }
225 }
226
Tomáš Kukrála18de112017-03-02 13:57:47 +0100227 stage('Install Kubernetes control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200228 orchestrate.installKubernetesControl(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100229 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100230 }
231
Tomáš Kukrála18de112017-03-02 13:57:47 +0100232 // install openstack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200233 if (common.checkContains('STACK_INSTALL', 'openstack')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100234 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100235
Tomáš Kukrála18de112017-03-02 13:57:47 +0100236 stage('Install OpenStack infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200237 orchestrate.installOpenstackInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100238 }
239
Tomáš Kukrála18de112017-03-02 13:57:47 +0100240 stage('Install OpenStack control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200241 orchestrate.installOpenstackControl(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100242 }
243
244 stage('Install OpenStack network') {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100245
Jakub Josef3c7915f2017-05-24 11:23:57 +0200246 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200247 orchestrate.installContrailNetwork(saltMaster)
Jakub Josef3c7915f2017-05-24 11:23:57 +0200248 } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200249 orchestrate.installOpenstackNetwork(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100250 }
251
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200252 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
253 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100254 }
255
Vasyl Saienko58ccaee2017-07-17 09:34:13 +0300256 if (salt.testTarget(saltMaster, 'I@ironic:conductor')){
257 stage('Install OpenStack Ironic conductor') {
258 orchestrate.installIronicConductor(saltMaster)
259 }
260 }
261
262
Tomáš Kukrála18de112017-03-02 13:57:47 +0100263 stage('Install OpenStack compute') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200264 orchestrate.installOpenstackCompute(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100265
Jakub Josef3c7915f2017-05-24 11:23:57 +0200266 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200267 orchestrate.installContrailCompute(saltMaster)
Tomáš Kukráld5a40af2017-03-07 15:34:58 +0100268 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100269 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100270
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100271 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100272
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100273
Martin Polreichbb6f5752017-06-30 12:37:41 +0200274 if (common.checkContains('STACK_INSTALL', 'sl-legacy')) {
275 stage('Install StackLight v1') {
276 orchestrate.installStacklightv1Control(saltMaster)
277 orchestrate.installStacklightv1Client(saltMaster)
278 }
279 }
280
Jakub Josef3c7915f2017-05-24 11:23:57 +0200281 if (common.checkContains('STACK_INSTALL', 'stacklight')) {
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100282 stage('Install StackLight') {
Martin Polreichbb6f5752017-06-30 12:37:41 +0200283 orchestrate.installDockerSwarm(saltMaster)
284 orchestrate.installStacklight(saltMaster)
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100285 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100286 }
287
Tomáš Kukrála18de112017-03-02 13:57:47 +0100288 //
289 // Test
290 //
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200291 def artifacts_dir = '_artifacts/'
Tomáš Kukrála18de112017-03-02 13:57:47 +0100292
Jakub Josef3c7915f2017-05-24 11:23:57 +0200293 if (common.checkContains('STACK_TEST', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100294 stage('Run k8s bootstrap tests') {
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200295 def image = 'tomkukral/k8s-scripts'
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200296 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200297
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200298 // run image
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200299 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200300
301 // collect output
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200302 sh "mkdir -p ${artifacts_dir}"
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200303 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200304 writeFile file: "${artifacts_dir}${output_file}", text: file_content
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200305 sh "cat ${artifacts_dir}${output_file}"
306
307 // collect artifacts
308 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
Tomáš Kukrála18de112017-03-02 13:57:47 +0100309 }
310
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200311 stage('Run k8s conformance e2e tests') {
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200312 //test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, TEST_K8S_CONFORMANCE_IMAGE)
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200313
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200314 def image = TEST_K8S_CONFORMANCE_IMAGE
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200315 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200316
317 // run image
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200318 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200319
320 // collect output
321 sh "mkdir -p ${artifacts_dir}"
322 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
323 writeFile file: "${artifacts_dir}${output_file}", text: file_content
324 sh "cat ${artifacts_dir}${output_file}"
325
326 // collect artifacts
327 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
328 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100329 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100330
Jakub Josef3c7915f2017-05-24 11:23:57 +0200331 if (common.checkContains('STACK_TEST', 'openstack')) {
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200332 if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
333 test.install_docker(saltMaster, TEST_TEMPEST_TARGET)
Tatyana Leontovicha6c02912017-07-10 20:02:18 +0300334 }
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400335 stage('Run OpenStack tests') {
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200336 test.runTempestTests(saltMaster, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400337 }
338
339 stage('Copy Tempest results to config node') {
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +0200340 test.copyTempestResults(saltMaster, TEST_TEMPEST_TARGET)
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400341 }
342 }
343
Tomáš Kukrál53224c22017-07-26 10:53:20 +0200344 if (common.checkContains('STACK_INSTALL', 'finalize')) {
345 stage('Finalize') {
346 salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100347 }
348 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100349 } catch (Throwable e) {
350 currentBuild.result = 'FAILURE'
351 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100352 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100353
Tomáš Kukrál96b12d52017-03-07 22:43:37 +0100354
Tomáš Kukrála18de112017-03-02 13:57:47 +0100355 //
356 // Clean
357 //
358
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100359 if (STACK_TYPE == 'heat') {
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100360 // send notification
Jakub Josef3c7915f2017-05-24 11:23:57 +0200361 common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100362
Jakub Josef3c7915f2017-05-24 11:23:57 +0200363 if (STACK_DELETE.toBoolean() == true) {
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100364 common.errorMsg('Heat job cleanup triggered')
365 stage('Trigger cleanup job') {
Tomáš Kukrálea079922017-06-22 09:12:15 +0200366 build(job: STACK_CLEANUP_JOB, parameters: [
367 [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME],
368 [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE],
369 [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL],
370 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS],
371 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT],
372 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN],
373 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID],
374 [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN],
375 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT],
376 [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION]
377 ])
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100378 }
379 } else {
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100380 if (currentBuild.result == 'FAILURE') {
381 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 +0100382
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100383 if (SALT_MASTER_URL) {
384 common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
385 }
Tomáš Kukrálb908dac2017-03-07 18:58:35 +0100386 }
387
Tomáš Kukrála18de112017-03-02 13:57:47 +0100388 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100389 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100390 }
391 }
392}