From c4264462b18487a09a489c69adb33a9d2547b873 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Wed, 8 Feb 2023 15:51:57 +0100 Subject: [PATCH] ci/e2e: make copying of nightly artifacts work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.combined | 2 ++ ci/tests/Jenkinsfile.e2e-nightly | 18 ++++++++++++------ ci/tests/Jenkinsfile.e2e-prs | 10 ++++++++-- ci/tests/Jenkinsfile.e2e-upgrade | 2 ++ test/appium/support/base_test_report.py | 4 ++-- test/appium/support/github_report.py | 2 -- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index 78dcd04134..5cf9e69c55 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -8,6 +8,8 @@ pipeline { disableConcurrentBuilds() /* Prevent Jenkins jobs from running forever */ timeout(time: 40, unit: 'MINUTES') + /* Allow copying of artifacts from this job. */ + copyArtifactPermission('/status-mobile/e2e/*') /* Limit builds retained */ buildDiscarder(logRotator( numToKeepStr: '10', diff --git a/ci/tests/Jenkinsfile.e2e-nightly b/ci/tests/Jenkinsfile.e2e-nightly index 43d014378b..890016fccb 100644 --- a/ci/tests/Jenkinsfile.e2e-nightly +++ b/ci/tests/Jenkinsfile.e2e-nightly @@ -1,3 +1,5 @@ +library 'status-jenkins-lib@v1.6.5' + pipeline { agent { label 'linux' } @@ -18,13 +20,17 @@ pipeline { disableConcurrentBuilds() } - stages { - stage('Prep') { + stage('Fetch') { + when { expression { !params.APK_URL } } steps { script { - if (params.PR_ID == null) { - error("PR_ID parameter not set!") - } + copyArtifacts( + projectName: "status-mobile/nightly", + filter: '*-x86.apk', + /* WARNING: This copies the latest available artifact. */ + selector: lastWithArtifacts(), + ) + apk_path = "${env.WORKSPACE}/${utils.findFile('*-x86.apk')}" } } } @@ -73,7 +79,7 @@ pipeline { -m testrail_id \ -m \"new_ui_critical or new_ui_medium\" \ -k \"${params.KEYWORD_EXPRESSION}\" \ - --apk=${params.APK_NAME} + --apk=${params.APK_URL ?: apk_path} """ } } diff --git a/ci/tests/Jenkinsfile.e2e-prs b/ci/tests/Jenkinsfile.e2e-prs index f612b446ee..6fcc2ef46a 100644 --- a/ci/tests/Jenkinsfile.e2e-prs +++ b/ci/tests/Jenkinsfile.e2e-prs @@ -14,6 +14,10 @@ pipeline { name: 'PR_ID', description: 'ID of the Pull Request triggering this build.', ) + string( + name: 'APK_URL', + description: 'Optional, set if job require APK to be downloaded from URL.', + ) string( name: 'KEYWORD_EXPRESSION', description: 'This will run tests which contain names that match the given string expression (Optional)', @@ -54,9 +58,11 @@ pipeline { } stage('Fetch') { - steps { script { /* WARNING: This copies the latest available artifact. */ + when { expression { !params.APK_URL } } + steps { script { copyArtifacts( projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}", + /* WARNING: This copies the latest available artifact. */ selector: lastWithArtifacts(), ) apk_path = "${env.WORKSPACE}/${utils.findFile('result/*.apk')}" @@ -119,7 +125,7 @@ pipeline { --rerun_count=2 \ --testrail_report=True \ -k \"${params.KEYWORD_EXPRESSION}\" \ - --apk=${apk_path} \ + --apk=${params.APK_URL ?: apk_path} \ --build=PR-${params.PR_ID}-${utils.timestamp()} \ --pr_number=${params.PR_ID} \ ${extraPytestOpts} diff --git a/ci/tests/Jenkinsfile.e2e-upgrade b/ci/tests/Jenkinsfile.e2e-upgrade index 740676b906..108ed42b11 100644 --- a/ci/tests/Jenkinsfile.e2e-upgrade +++ b/ci/tests/Jenkinsfile.e2e-upgrade @@ -1,3 +1,5 @@ +library 'status-jenkins-lib@v1.6.5' + pipeline { agent { label 'linux' } diff --git a/test/appium/support/base_test_report.py b/test/appium/support/base_test_report.py index 5ff320fa63..e00f700152 100644 --- a/test/appium/support/base_test_report.py +++ b/test/appium/support/base_test_report.py @@ -108,9 +108,9 @@ class BaseTestReport: return url @staticmethod - def get_jenkins_link_to_rerun_e2e(branch_name="develop", pr_id="", apk_name="", tr_case_ids=""): + def get_jenkins_link_to_rerun_e2e(branch_name="develop", pr_id="", tr_case_ids=""): return 'https://ci.status.im/job/status-mobile/job/e2e/job/status-app-prs-rerun/parambuild/' \ - '?BRANCH_NAME=%s&APK_NAME=%s&PR_ID=%s&TR_CASE_IDS=%s' % (branch_name, apk_name, pr_id, tr_case_ids) + '?BRANCH_NAME=%s&PR_ID=%s&TR_CASE_IDS=%s' % (branch_name, pr_id, tr_case_ids) def get_sauce_final_screenshot_url(self, job_id): return 'https://media.giphy.com/media/9M5jK4GXmD5o1irGrF/giphy.gif' diff --git a/test/appium/support/github_report.py b/test/appium/support/github_report.py index 0e30871ea0..27a658aa05 100644 --- a/test/appium/support/github_report.py +++ b/test/appium/support/github_report.py @@ -71,13 +71,11 @@ class GithubHtmlReport(BaseTestReport): if not_executed_tests: html += "
  • Rerun not executed tests
  • " % self.get_jenkins_link_to_rerun_e2e( pr_id=pr_id, - apk_name=apk_name, tr_case_ids=','.join([str(i) for i in tests])) if failed_tests: html += "
  • Rerun failed tests
  • " % self.get_jenkins_link_to_rerun_e2e( pr_id=pr_id, - apk_name=apk_name, tr_case_ids=','.join([str(test.testrail_case_id) for test in tests])) if not not_executed_tests: