blob: 5875b3cc23010ca55d2f0c5bdf45e1a49c3182ca [file] [log] [blame]
Hanna Arhipova4759ae42021-01-11 12:48:14 +02001/**
2 *
3 * Deploy the product cluster using Jenkins master on CICD cluster
4 *
5 * Expected parameters:
6
7 * ENV_NAME Fuel-devops environment name
8 * PASSED_STEPS Steps passed to install components using Jenkins on CICD cluster: "salt,core,cicd,openstack:3200,stacklight:2400",
9 where 3200 and 2400 might be timeouts (not used in the testing pipeline)
10 * RUN_TEST_OPTS Pytest option -k or -m, with expression to select necessary tests. Additional pytest options are allowed.
11 * PARENT_NODE_NAME Name of the jenkins slave to create the environment
12 * PARENT_WORKSPACE Path to the workspace of the parent job to use tcp-qa repo
13 * TCP_QA_REFS Reference to the tcp-qa change on Gerrit, like refs/changes/46/418546/41
14 * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job
15 * TEMPEST_IMAGE_VERSION Tempest image version: pike by default, can be queens.
16 * TEMPEST_TARGET Node where tempest will be run
17 * MAKE_SNAPSHOT_STAGES optional, use "dos.py snapshot" to snapshot stages
18 */
19
20@Library('tcp-qa')_
21
22def common = new com.mirantis.mk.Common()
23def shared = new com.mirantis.system_qa.SharedPipeline()
24
25def steps = env.PASSED_STEPS
26def make_snapshot_stages = false
Hanna Arhipova885a2ed2021-03-05 20:00:52 +020027def env.LAB_CONFIG_NAME = env.LAB_CONFIG_NAME ?: env.ENV_NAME
Hanna Arhipova4759ae42021-01-11 12:48:14 +020028
29timeout(time: 23, unit: 'HOURS') {
30 node ("${PARENT_NODE_NAME}") {
31 if (! fileExists("${PARENT_WORKSPACE}")) {
32 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
33 }
34 dir("${PARENT_WORKSPACE}") {
35 env.slave_workdir = pwd()
36 if (env.TCP_QA_REFS) {
37 stage("Update working dir to patch ${TCP_QA_REFS}") {
38 shared.update_working_dir()
39 }
40 }
41
42 stage("Run tests") {
43 try {
44 if (env.RUN_TEST_OPTS) {
45 shared.swarm_run_pytest(steps, "${PARENT_NODE_NAME}", make_snapshot_stages)
46 } else {
47 common.printMsg("RUN_TEST_OPTS is empty, skipping 'swarm-run-pytest' job", "green")
48 }
49 } catch (e) {
50 common.printMsg("Tests are failed: " + e.message, "purple")
51 }
52 } // stage("Run tests")
53
54 stage("Archive all xml reports") {
55 dir("${env.slave_workdir }") {
56 archiveArtifacts artifacts: "**/*.xml,**/*.ini,**/*.log,**/*.tar.gz"
57 }
58 }
59
60 stage("report results to testrail from jenkins master") {
61 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
62 common.printMsg("Running on: " + env.PARENT_NODE_NAME, "blue")
63 shared.verbose_sh("""\
64 [ -d /home/jenkins/venv_testrail_reporter ] || virtualenv --python=python3.7 /home/jenkins/venv_testrail_reporter""", true, false, true)
65 shared.run_cmd("""\
66 . /home/jenkins/venv_testrail_reporter/bin/activate; pip install git+https://github.com/dis-xcom/testrail_reporter -U""")
67 shared.swarm_testrail_report(steps, env.PARENT_NODE_NAME)
68 } else {
69 common.printMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
70 }
71 } // stage("report results to testrail from jenkins master")
72 stage("Store TestRail reports to job description") {
73 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
74 if (fileExists("description.txt")) {
75 def String description = readFile("description.txt")
76 currentBuild.description += "${description}"
77 }
78 } else {
79 common.printMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
80 }
81 } // stage("Store TestRail reports to job description")
82 } // dir
83 } // node
84} // timeout