blob: 58474b9f3709efb83cee3f2e54aa8b5071e29b2c [file] [log] [blame]
Dennis Dmitrievb3b37492018-07-08 21:23:00 +03001/**
2 *
3 * Deploy CICD cluster using Jenkins master on cfg01 node
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
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020010 * STACK_INSTALL Stacks to install using Jenkins on cfg01 node: "core,cicd"
11 * STACK_INSTALL_TIMEOUT Stacks installation timeout
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030012 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
13 * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job
14 *
15 */
16
17@Library('tcp-qa')_
18
19common = new com.mirantis.mk.Common()
20shared = new com.mirantis.system_qa.SharedPipeline()
21
22if (! env.PARENT_NODE_NAME) {
23 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
24}
25
Dennis Dmitriev201a35e2018-08-06 01:37:05 +030026currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
27
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020028def install_timeout = env.STACK_INSTALL_TIMEOUT.toInteger()
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030029
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020030timeout(time: install_timeout + 600, unit: 'SECONDS') {
31
32 node ("${PARENT_NODE_NAME}") {
33 if (! fileExists("${PARENT_WORKSPACE}")) {
34 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030035 }
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020036 dir("${PARENT_WORKSPACE}") {
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030037
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020038 if (! env.STACK_INSTALL) {
39 error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline"
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030040 }
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030041
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020042 if (env.TCP_QA_REFS) {
43 stage("Update working dir to patch ${TCP_QA_REFS}") {
44 shared.update_working_dir()
45 }
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030046 }
47
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030048 try {
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020049 // Install core and cicd
Dennis Dmitriev44f6db22018-10-31 16:07:56 +020050 stage("Run Jenkins job on salt-master [deploy_openstack:${env.STACK_INSTALL}]") {
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020051 shared.run_job_on_day01_node(env.STACK_INSTALL, install_timeout)
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030052 }
53
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020054 for (stack in "${env.STACK_INSTALL}".split(",")) {
55 stage("Sanity check the deployed component [${stack}]") {
56 shared.sanity_check_component(stack)
57 }
58 stage("Make environment snapshot [${stack}_deployed]") {
59 shared.devops_snapshot(stack)
60 }
61 } // for
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030062
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030063 } catch (e) {
64 common.printMsg("Job is failed", "purple")
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020065 shared.download_logs("deploy_drivetrain")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030066 throw e
67 } finally {
68 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
69 // and report appropriate data to TestRail
70 // TODO(ddmitriev): add checks for cicd cluster
71 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") {
72 shared.run_cmd("""\
73 dos.py destroy ${ENV_NAME}
74 """)
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030075 }
76 }
77
Dennis Dmitriev07d5b8a2018-10-29 19:43:00 +020078 } // dir
79 } // node
80}