sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 1 | /** |
| 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,stacklight" |
| 11 | * STACK_INSTALL_TIMEOUT Stacks installation timeout |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 12 | * TCP_QA_REFS Reference to the tcp-qa change on Gerrit, like refs/changes/46/418546/41 |
sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 13 | * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | @Library('tcp-qa')_ |
| 18 | |
| 19 | common = new com.mirantis.mk.Common() |
| 20 | shared = new com.mirantis.system_qa.SharedPipeline() |
| 21 | |
| 22 | if (! env.PARENT_NODE_NAME) { |
| 23 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 24 | } |
| 25 | |
| 26 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
| 27 | |
| 28 | def install_timeout = env.STACK_INSTALL_TIMEOUT.toInteger() |
| 29 | |
| 30 | timeout(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}'." |
| 35 | } |
| 36 | dir("${PARENT_WORKSPACE}") { |
| 37 | |
| 38 | if (! env.STACK_INSTALL) { |
| 39 | error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline" |
| 40 | } |
| 41 | |
| 42 | if (env.TCP_QA_REFS) { |
| 43 | stage("Update working dir to patch ${TCP_QA_REFS}") { |
| 44 | shared.update_working_dir() |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | try { |
| 49 | // Install the cluster |
| 50 | stage("Run Jenkins job on day01 [deploy_openstack:${env.STACK_INSTALL}]") { |
| 51 | shared.run_job_on_day01_node(env.STACK_INSTALL, install_timeout) |
| 52 | } |
| 53 | |
| 54 | for (stack in "${env.STACK_INSTALL}".split(",")) { |
| 55 | stage("Sanity check the deployed component [${stack}]") { |
| 56 | shared.sanity_check_component(stack) |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 57 | shared.run_cmd("""\ |
| 58 | if [ -f \$(pwd)/${ENV_NAME}_salt_deployed.ini ]; then |
| 59 | cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_${stack}_deployed.ini |
| 60 | fi |
| 61 | """) |
sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 62 | } |
| 63 | } // for |
| 64 | |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 65 | stage("Make environment snapshots for [${env.STACK_INSTALL}]") { |
| 66 | shared.devops_snapshot(env.STACK_INSTALL) |
| 67 | } |
| 68 | |
sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 69 | } catch (e) { |
| 70 | common.printMsg("Job is failed", "purple") |
| 71 | shared.download_logs("deploy_platform_${ENV_NAME}") |
| 72 | throw e |
| 73 | } finally { |
| 74 | // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'" |
| 75 | // and report appropriate data to TestRail |
| 76 | // TODO(ddmitriev): add checks for the installed stacks |
| 77 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") { |
| 78 | shared.run_cmd("""\ |
| 79 | dos.py destroy ${ENV_NAME} |
| 80 | """) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | } // dir |
| 85 | } // node |
| 86 | } |