Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [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 |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 10 | * STACK_INSTALL Stacks to install using Jenkins on CICD cluster: "openstack,stacklight" |
| 11 | * STACK_INSTALL_TIMEOUT Stacks installation timeout |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 12 | * 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 |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 14 | * MAKE_SNAPSHOT_STAGES optional, use "dos.py snapshot" to snapshot stages |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 15 | * |
| 16 | */ |
| 17 | |
| 18 | @Library('tcp-qa')_ |
| 19 | |
| 20 | common = new com.mirantis.mk.Common() |
| 21 | shared = new com.mirantis.system_qa.SharedPipeline() |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 22 | make_snapshot_stages = "${env.MAKE_SNAPSHOT_STAGES}" != "false" ? true : false |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 23 | |
| 24 | if (! env.PARENT_NODE_NAME) { |
| 25 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 26 | } |
| 27 | |
Dennis Dmitriev | 201a35e | 2018-08-06 01:37:05 +0300 | [diff] [blame] | 28 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
| 29 | |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 30 | def install_timeout = env.STACK_INSTALL_TIMEOUT.toInteger() |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 31 | |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 32 | timeout(time: install_timeout + 600, unit: 'SECONDS') { |
| 33 | |
| 34 | node ("${PARENT_NODE_NAME}") { |
| 35 | if (! fileExists("${PARENT_WORKSPACE}")) { |
| 36 | error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'." |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 37 | } |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 38 | dir("${PARENT_WORKSPACE}") { |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 39 | |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 40 | if (! env.STACK_INSTALL) { |
| 41 | error "'STACK_INSTALL' must contain one or more comma separated stack names for [deploy_openstack] pipeline" |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 42 | } |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 43 | |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 44 | if (env.TCP_QA_REFS) { |
| 45 | stage("Update working dir to patch ${TCP_QA_REFS}") { |
| 46 | shared.update_working_dir() |
| 47 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 48 | } |
| 49 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 50 | try { |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 51 | // Install the cluster |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 52 | stage("Run Jenkins job on CICD [deploy_openstack:${env.STACK_INSTALL}]") { |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 53 | shared.run_job_on_cicd_nodes(env.STACK_INSTALL, install_timeout) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 54 | } |
| 55 | |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 56 | for (stack in "${env.STACK_INSTALL}".split(",")) { |
| 57 | stage("Sanity check the deployed component [${stack}]") { |
| 58 | shared.sanity_check_component(stack) |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 59 | |
| 60 | // If oslo_config INI file ${ENV_NAME}_salt_deployed.ini exists, |
| 61 | // then make a copy for the created snapshot to allow the system |
| 62 | // tests to revert this snapshot along with the metadata from the INI file. |
| 63 | shared.run_cmd("""\ |
| 64 | if [ -f \$(pwd)/${ENV_NAME}_salt_deployed.ini ]; then |
| 65 | cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_${stack}_deployed.ini |
| 66 | fi |
| 67 | """) |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 68 | } |
| 69 | } // for |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 70 | |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 71 | if (make_snapshot_stages) { |
| 72 | stage("Make environment snapshots for [${env.STACK_INSTALL}]") { |
| 73 | shared.devops_snapshot(env.STACK_INSTALL) |
| 74 | } |
| 75 | } |
| 76 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 77 | } catch (e) { |
| 78 | common.printMsg("Job is failed", "purple") |
Dennis Dmitriev | 9cd5c13 | 2018-12-12 17:10:47 +0200 | [diff] [blame] | 79 | shared.download_logs("deploy_platform_${ENV_NAME}") |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 80 | throw e |
| 81 | } finally { |
| 82 | // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'" |
| 83 | // and report appropriate data to TestRail |
| 84 | // TODO(ddmitriev): add checks for the installed stacks |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 85 | if (make_snapshot_stages) { |
| 86 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") { |
| 87 | shared.run_cmd("""\ |
| 88 | dos.py destroy ${ENV_NAME} |
| 89 | """) |
| 90 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 94 | } // dir |
| 95 | } // node |
Dennis Dmitriev | 1f08b0c | 2019-05-27 17:03:53 +0300 | [diff] [blame] | 96 | } // timeout |