sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 1 | @Library('tcp-qa')_ |
| 2 | |
| 3 | def common = new com.mirantis.mk.Common() |
| 4 | def shared = new com.mirantis.system_qa.SharedPipeline() |
| 5 | def steps = "hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL |
| 6 | |
| 7 | currentBuild.description = "${NODE_NAME}:${ENV_NAME}" |
| 8 | |
| 9 | def deploy(shared, common, steps) { |
| 10 | def report_text = '' |
| 11 | try { |
| 12 | |
| 13 | stage("Clean the environment and clone tcp-qa") { |
| 14 | shared.prepare_working_dir() |
| 15 | } |
| 16 | |
| 17 | stage("Create environment, generate model, bootstrap the salt-cluster") { |
| 18 | // steps: "hardware,create_model,salt" |
| 19 | shared.swarm_bootstrap_salt_cluster_devops() |
| 20 | } |
| 21 | |
| 22 | stage("Deploy platform components from day01 Jenkins") { |
| 23 | // steps: env.PLATFORM_STACK_INSTALL |
| 24 | shared.swarm_deploy_platform_non_cicd(env.PLATFORM_STACK_INSTALL, env.PLATFORM_STACK_INSTALL_TIMEOUT) |
| 25 | } |
| 26 | |
| 27 | currentBuild.result = 'SUCCESS' |
| 28 | |
| 29 | } catch (e) { |
| 30 | common.printMsg("Deploy is failed: " + e.message , "purple") |
| 31 | report_text = e.message |
| 32 | def snapshot_name = "deploy_failed" |
| 33 | shared.run_cmd("""\ |
| 34 | dos.py suspend ${ENV_NAME} || true |
| 35 | dos.py snapshot ${ENV_NAME} ${snapshot_name} || true |
| 36 | """) |
| 37 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") { |
| 38 | shared.run_cmd("""\ |
| 39 | dos.py resume ${ENV_NAME} || true |
| 40 | """) |
| 41 | } |
| 42 | shared.devops_snapshot_info(snapshot_name) |
| 43 | throw e |
| 44 | } finally { |
| 45 | shared.create_deploy_result_report(steps, currentBuild.result, report_text) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | def test(shared, common, steps) { |
| 50 | try { |
| 51 | stage("Run tests") { |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 52 | shared.swarm_run_pytest(steps, "${NODE_NAME}") |
sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | } catch (e) { |
| 56 | common.printMsg("Tests are failed: " + e.message, "purple") |
| 57 | def snapshot_name = "tests_failed" |
| 58 | shared.run_cmd("""\ |
| 59 | dos.py suspend ${ENV_NAME} || true |
| 60 | dos.py snapshot ${ENV_NAME} ${snapshot_name} || true |
| 61 | """) |
| 62 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") { |
| 63 | shared.run_cmd("""\ |
| 64 | dos.py resume ${ENV_NAME} || true |
| 65 | """) |
| 66 | } |
| 67 | shared.devops_snapshot_info(snapshot_name) |
| 68 | throw e |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // main |
| 73 | // Temporary disable throttle to check how it will run |
| 74 | //throttle(['fuel_devops_environment']) { |
| 75 | node ("${NODE_NAME}") { |
| 76 | try { |
| 77 | // run deploy stages |
| 78 | deploy(shared, common, steps) |
| 79 | // run test stages |
| 80 | test(shared, common, steps) |
| 81 | } catch (e) { |
| 82 | common.printMsg("Job is failed: " + e.message, "purple") |
| 83 | throw e |
| 84 | } finally { |
| 85 | // shutdown the environment if required |
| 86 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") { |
| 87 | shared.run_cmd("""\ |
| 88 | dos.py destroy ${ENV_NAME} || true |
| 89 | """) |
| 90 | } |
| 91 | |
| 92 | stage("Archive all xml reports") { |
| 93 | archiveArtifacts artifacts: "**/*.xml,**/*.ini,**/*.log,**/*.tar.gz" |
| 94 | } |
| 95 | stage("report results to testrail") { |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 96 | shared.swarm_testrail_report(steps, "${NODE_NAME}") |
sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 97 | } |
| 98 | stage("Store TestRail reports to job description") { |
| 99 | def String description = readFile("description.txt") |
| 100 | currentBuild.description += "\n${description}" |
| 101 | } |
| 102 | |
| 103 | } |
| 104 | } |
| 105 | //} |