blob: e1443725da6782b3214b8141c6faa2ab7e54d725 [file] [log] [blame]
Dennis Dmitrievb3b37492018-07-08 21:23:00 +03001/**
2 *
3 * Deploy the product cluster using Jenkins master on CICD cluster
4 *
5 * Expected parameters:
6
7 * PARENT_NODE_NAME Name of the jenkins slave to create the environment
8 * PARENT_WORKSPACE Path to the workspace of the parent job to use tcp-qa repo
9 * ENV_NAME Fuel-devops environment name
10 * STACK_INSTALL Stacks to install using Jenkins on CICD cluster: "openstack:3200,stacklight:2400", where 3200 and 2400 are timeouts
11 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
12 * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job
13 *
14 */
15
16@Library('tcp-qa')_
17
18common = new com.mirantis.mk.Common()
19shared = new com.mirantis.system_qa.SharedPipeline()
20
21if (! env.PARENT_NODE_NAME) {
22 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
23}
24
25node ("${PARENT_NODE_NAME}") {
26 if (! fileExists("${PARENT_WORKSPACE}")) {
27 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
28 }
29 dir("${PARENT_WORKSPACE}") {
30 try {
31
32 if (! env.STACK_INSTALL) {
33 error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline"
34 }
35
36 // Install the cluster
37 def stack
38 def timeout
39
40 for (element in "${STACK_INSTALL}".split(",")) {
41 if (element.contains(':')) {
42 (stack, timeout) = element.split(':')
43 } else {
44 stack = element
45 timeout = '1800'
46 }
47 stage("Run Jenkins job on CICD [deploy_openstack:${stack}]") {
48 shared.run_job_on_cicd_nodes(stack, timeout)
49 }
50
51 stage("Sanity check the deployed component [${stack}]") {
52 shared.sanity_check_component(stack)
53 }
54
55 stage("Make environment snapshot [${stack}_deployed]") {
56 shared.devops_snapshot(stack)
57 }
58 }
59
60 } catch (e) {
61 common.printMsg("Job failed", "red")
62 throw e
63 } finally {
64 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
65 // and report appropriate data to TestRail
66 // TODO(ddmitriev): add checks for the installed stacks
67 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") {
68 shared.run_cmd("""\
69 dos.py destroy ${ENV_NAME}
70 """)
71 }
72 }
73 }
74}