From e61bd769a8bb71200c6dc7f1176acb94f411059b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 6 Feb 2023 11:58:22 +0100 Subject: [PATCH] ci: fetch E2E APK from android-e2e jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using `copyArtifacts()` is more reliable and faster then fetching APKs based on URLs acquired by parsing GitHub comments from Jenkins builds. Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.combined | 2 +- ci/tests/Jenkinsfile.e2e-nightly | 13 +++++++-- ci/tests/Jenkinsfile.e2e-prs | 48 +++++++++++++++++++++----------- ci/tests/Jenkinsfile.e2e-upgrade | 24 ++++++++++++---- 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index 4f75eac06f..78dcd04134 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -105,7 +105,7 @@ pipeline { e2eApk = utils.getEnv(apke2e, 'SAUCE_URL') build( job: 'status-mobile/e2e/status-app-nightly', - parameters: [string(name: 'APK_NAME', value: e2eApk)], + parameters: [string(name: 'APK_URL', value: e2eApk)], wait: false ) } } diff --git a/ci/tests/Jenkinsfile.e2e-nightly b/ci/tests/Jenkinsfile.e2e-nightly index a29a4c0877..b498e14e46 100644 --- a/ci/tests/Jenkinsfile.e2e-nightly +++ b/ci/tests/Jenkinsfile.e2e-nightly @@ -4,8 +4,8 @@ pipeline { parameters { string( - name: 'APK_NAME', - description: 'Filename of APK uploaded to SauceLabs.', + name: 'APK_URL', + description: 'URL of APK uploaded to SauceLabs.', ) string( name: 'KEYWORD_EXPRESSION', @@ -20,6 +20,14 @@ pipeline { stages { + stage('Prep') { + steps { script { + if (params.PR_ID == null) { + error("PR_ID parameter not set!") + } + } } + } + stage('Setup') { steps { script { dir('test/appium') { @@ -27,6 +35,7 @@ pipeline { } } } } + stage('Test') { steps { withCredentials([ diff --git a/ci/tests/Jenkinsfile.e2e-prs b/ci/tests/Jenkinsfile.e2e-prs index 098bb160f8..563d3405c6 100644 --- a/ci/tests/Jenkinsfile.e2e-prs +++ b/ci/tests/Jenkinsfile.e2e-prs @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.6.3' +library 'status-jenkins-lib@v1.6.5' pipeline { @@ -10,16 +10,6 @@ pipeline { description: 'Name of the branch to checkout and build.', defaultValue: 'develop', ) -/* Commented to use TEST_MARKERS values from job params - string( - name: 'TEST_MARKERS', - description: 'Marker expression for matching tests to run.', - defaultValue: 'new_ui_critical', - ) */ - string( - name: 'APK_NAME', - description: 'Filename of APK uploaded to SauceLabs, path, or URL.', - ) string( name: 'PR_ID', description: 'ID of the Pull Request triggering this build.', @@ -34,6 +24,19 @@ pipeline { description: 'IDs of the TestRail case, separated by a comma (Optional)', defaultValue: '', ) + /* FIXME: Remove this no longer relevant argument */ + string( + name: 'APK_NAME', + description: 'OBSOLETE ARGUMENT TO BE REMOVED', + defaultValue: 'DUMMY', + ) + /* Commented to use TEST_MARKERS values from job params + string( + name: 'TEST_MARKERS', + description: 'Marker expression for matching tests to run.', + defaultValue: 'new_ui_critical', + ) + */ } options { @@ -41,12 +44,25 @@ pipeline { } stages { - stage('Checks') { + stage('Prep') { steps { script { - if (params.APK_NAME == null) { error("APK_NAME parameter not set!") } - if (params.PR_ID == null) { error("PR_ID parameter not set!") } + currentBuild.displayName = "PR-${params.PR_ID}" + if (params.PR_ID == null) { + error("PR_ID parameter not set!") + } } } } + + stage('Fetch') { + steps { script { /* WARNING: This copies the latest available artifact. */ + copyArtifacts( + projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}", + selector: lastWithArtifacts(), + ) + apk_path = "${env.PWD}/${utils.findFile('result/*.apk')}" + } } + } + stage('Setup') { steps { script { dir('test/appium') { @@ -54,9 +70,9 @@ pipeline { } } } } + stage('Test') { steps { script { - currentBuild.displayName = "PR-${params.PR_ID}" /* for managing optional arguments */ def extraPytestOpts = '' if (params.TR_CASE_IDS != '') { @@ -103,7 +119,7 @@ pipeline { --rerun_count=2 \ --testrail_report=True \ -k \"${params.KEYWORD_EXPRESSION}\" \ - --apk=${params.APK_NAME} \ + --apk=${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 b442b317fc..5a81707b6c 100644 --- a/ci/tests/Jenkinsfile.e2e-upgrade +++ b/ci/tests/Jenkinsfile.e2e-upgrade @@ -4,12 +4,12 @@ pipeline { parameters { string( - name: 'APK_NAME', - description: 'Filename of APK uploaded to SauceLabs (base for upgrade, usually release build)', + name: 'APK_URL', + description: 'URL of APK to be tested(base for upgrade, usually release build)', ) string( - name: 'APK_NAME_UPGRADE', - description: 'Filename of APK of upgraded application (installed on top of base)', + name: 'APK_URL_UPGRADE', + description: 'URL of APK of upgraded application (installed on top of base)', ) string( name: 'KEYWORD_EXPRESSION', @@ -29,6 +29,17 @@ pipeline { stages { + stage('Prep') { + steps { script { + if (params.APK_URL == null) { + error("APK_URL parameter not set!") + } + if (params.APK_URL_UPGRADE == null) { + error("APK_URL_UPGRADE parameter not set!") + } + } } + } + stage('Setup') { steps { script { dir('test/appium') { @@ -36,6 +47,7 @@ pipeline { } } } } + stage('Test') { steps { script { /* for managing optional arguments */ @@ -77,8 +89,8 @@ pipeline { --numprocesses 4 \ --rerun_count=2 \ --testrail_report=True \ - --apk=${params.APK_NAME} \ - --apk_upgrade=${params.APK_NAME_UPGRADE} \ + --apk=${params.APK_URL} \ + --apk_upgrade=${params.APK_URL_UPGRADE} \ ${extraPytestOpts} """ }