Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 1 | /** |
| 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 |
| 10 | * STACK_INSTALL Stacks to install using Jenkins on cfg01 node: "core:1800,cicd:1800", where 1800 is timeout |
| 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 | |
| 18 | common = new com.mirantis.mk.Common() |
| 19 | shared = new com.mirantis.system_qa.SharedPipeline() |
| 20 | |
| 21 | if (! env.PARENT_NODE_NAME) { |
| 22 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 23 | } |
| 24 | |
Dennis Dmitriev | 201a35e | 2018-08-06 01:37:05 +0300 | [diff] [blame] | 25 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
| 26 | |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 27 | node ("${PARENT_NODE_NAME}") { |
| 28 | if (! fileExists("${PARENT_WORKSPACE}")) { |
| 29 | error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'." |
| 30 | } |
| 31 | dir("${PARENT_WORKSPACE}") { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 32 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 33 | if (! env.STACK_INSTALL) { |
| 34 | error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline" |
| 35 | } |
| 36 | |
| 37 | if (env.TCP_QA_REFS) { |
| 38 | stage("Update working dir to patch ${TCP_QA_REFS}") { |
| 39 | shared.update_working_dir() |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // Install core and cicd |
| 44 | def stack |
| 45 | def timeout |
| 46 | |
| 47 | for (element in "${env.STACK_INSTALL}".split(",")) { |
| 48 | if (element.contains(':')) { |
| 49 | (stack, timeout) = element.split(':') |
| 50 | } else { |
| 51 | stack = element |
| 52 | timeout = '1800' |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 53 | } |
| 54 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 55 | try { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 56 | stage("Run Jenkins job on salt-master [deploy_openstack:${stack}]") { |
| 57 | shared.run_job_on_day01_node(stack, timeout) |
| 58 | } |
| 59 | |
| 60 | stage("Sanity check the deployed component [${stack}]") { |
| 61 | shared.sanity_check_component(stack) |
| 62 | } |
| 63 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 64 | } catch (e) { |
| 65 | common.printMsg("Job is failed", "purple") |
| 66 | shared.download_logs("deploy_${stack}") |
| 67 | throw e |
| 68 | } finally { |
| 69 | // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'" |
| 70 | // and report appropriate data to TestRail |
| 71 | // TODO(ddmitriev): add checks for cicd cluster |
| 72 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") { |
| 73 | shared.run_cmd("""\ |
| 74 | dos.py destroy ${ENV_NAME} |
| 75 | """) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 79 | stage("Make environment snapshot [${stack}_deployed]") { |
| 80 | shared.devops_snapshot(stack) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 81 | } |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 82 | |
| 83 | } // for |
| 84 | } // dir |
| 85 | } // node |