blob: 3e96c841ac9ad01245da8f8aec8186e11e7c1adf [file] [log] [blame]
Dennis Dmitrievfde667f2018-07-23 16:26:50 +03001@Library('tcp-qa')_
2
3def common = new com.mirantis.mk.Common()
4def shared = new com.mirantis.system_qa.SharedPipeline()
5def steps = "hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL
6
Dennis Dmitriev201a35e2018-08-06 01:37:05 +03007currentBuild.description = "${NODE_NAME}:${ENV_NAME}"
8
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +03009def deploy(shared, common, steps) {
10 def report_text = ''
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030011 try {
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030012
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030013 stage("Clean the environment and clone tcp-qa") {
14 shared.prepare_working_dir()
15 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030016
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030017 stage("Create environment, generate model, bootstrap the salt-cluster") {
18 // steps: "hardware,create_model,salt"
19 shared.swarm_bootstrap_salt_cluster_devops()
20 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030021
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030022 stage("Install core infrastructure and deploy CICD nodes") {
23 // steps: env.DRIVETRAIN_STACK_INSTALL
24 shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL)
25 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030026
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030027 stage("Deploy platform components") {
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030028 // steps: env.PLATFORM_STACK_INSTALL
29 shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL)
30 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030031
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030032 currentBuild.result = 'SUCCESS'
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030033
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030034 } catch (e) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030035 common.printMsg("Deploy is failed: " + e.message , "red")
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030036 shared.run_cmd("""\
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030037 dos.py suspend ${ENV_NAME} || true
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030038 dos.py snapshot ${ENV_NAME} deploy_failed || true
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030039 """)
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030040 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") {
41 shared.run_cmd("""\
42 dos.py resume ${ENV_NAME} || true
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030043 """)
44 } else {
45 shared.run_cmd("""\
46 dos.py destroy ${ENV_NAME} || true
47 """)
48 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030049 report_text = e.message
50 throw e
51 } finally {
52 shared.create_deploy_result_report(steps, currentBuild.result, report_text)
53 }
54}
55
56def test(shared, common, steps) {
57 try {
58 stage("Run tests") {
59 shared.swarm_run_pytest(steps)
60 }
61
62 } catch (e) {
63 common.printMsg("Tests are failed: " + e.message, "red")
64 shared.run_cmd("""\
65 dos.py suspend ${ENV_NAME} || true
66 dos.py snapshot ${ENV_NAME} tests_failed || true
67 """)
68 throw e
69 } finally {
70 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") {
71 shared.run_cmd("""\
72 dos.py resume ${ENV_NAME} || true
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030073 """)
74 } else {
75 shared.run_cmd("""\
76 dos.py destroy ${ENV_NAME} || true
77 """)
78 }
79 }
80}
81
82// main
83throttle(['fuel_devops_environment']) {
84 node ("${NODE_NAME}") {
85 try {
86 deploy(shared, common, steps)
87 test(shared, common, steps)
88 } catch (e) {
89 common.printMsg("Job is failed: " + e.message, "red")
90 throw e
91 } finally {
92 shared.swarm_testrail_report(steps)
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030093 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030094 }
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030095}