Add testrail reporter for cicd deployments
Related task: #PROD-21660
Change-Id: I7e1406b82697895db630ec0d470c05d93ac8c81f
diff --git a/jobs/pipelines/deploy-cicd-and-run-tests.groovy b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
index 7566b34..27dbfd7 100644
--- a/jobs/pipelines/deploy-cicd-and-run-tests.groovy
+++ b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
@@ -6,8 +6,8 @@
currentBuild.description = "${NODE_NAME}:${ENV_NAME}"
-throttle(['fuel_devops_environment']) {
- node ("${NODE_NAME}") {
+def deploy(shared, common, steps) {
+ def report_text = ''
try {
stage("Clean the environment and clone tcp-qa") {
@@ -29,20 +29,14 @@
shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL)
}
- stage("Run tests") {
- shared.swarm_run_pytest(steps)
- }
+ currentBuild.result = 'SUCCESS'
} catch (e) {
- common.printMsg("Job failed", "red")
+ common.printMsg("Deploy is failed: " + e.message , "red")
shared.run_cmd("""\
dos.py suspend ${ENV_NAME} || true
- dos.py snapshot ${ENV_NAME} test_failed || true
+ dos.py snapshot ${ENV_NAME} deploy_failed || true
""")
- throw e
- } finally {
- // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
- // and report appropriate data to TestRail
if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") {
shared.run_cmd("""\
dos.py resume ${ENV_NAME} || true
@@ -54,8 +48,52 @@
dos.py destroy ${ENV_NAME} || true
""")
}
- shared.report_deploy_result(steps)
- shared.report_test_result()
+ report_text = e.message
+ throw e
+ } finally {
+ shared.create_deploy_result_report(steps, currentBuild.result, report_text)
+ }
+}
+
+def test(shared, common, steps) {
+ try {
+ stage("Run tests") {
+ shared.swarm_run_pytest(steps)
+ }
+
+ } catch (e) {
+ common.printMsg("Tests are failed: " + e.message, "red")
+ shared.run_cmd("""\
+ dos.py suspend ${ENV_NAME} || true
+ dos.py snapshot ${ENV_NAME} tests_failed || true
+ """)
+ throw e
+ } finally {
+ if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") {
+ shared.run_cmd("""\
+ dos.py resume ${ENV_NAME} || true
+ sleep 20 # Wait for I/O on the host calms down
+ dos.py time-sync ${ENV_NAME} || true
+ """)
+ } else {
+ shared.run_cmd("""\
+ dos.py destroy ${ENV_NAME} || true
+ """)
+ }
+ }
+}
+
+// main
+throttle(['fuel_devops_environment']) {
+ node ("${NODE_NAME}") {
+ try {
+ deploy(shared, common, steps)
+ test(shared, common, steps)
+ } catch (e) {
+ common.printMsg("Job is failed: " + e.message, "red")
+ throw e
+ } finally {
+ shared.swarm_testrail_report(steps)
}
}
}
\ No newline at end of file