ci/e2e: make copying of nightly artifacts work

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Churikova Tetiana 2023-02-08 15:51:57 +01:00 committed by Jakub Sokołowski
parent b1d4368154
commit c4264462b1
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
6 changed files with 26 additions and 12 deletions

View File

@ -8,6 +8,8 @@ pipeline {
disableConcurrentBuilds() disableConcurrentBuilds()
/* Prevent Jenkins jobs from running forever */ /* Prevent Jenkins jobs from running forever */
timeout(time: 40, unit: 'MINUTES') timeout(time: 40, unit: 'MINUTES')
/* Allow copying of artifacts from this job. */
copyArtifactPermission('/status-mobile/e2e/*')
/* Limit builds retained */ /* Limit builds retained */
buildDiscarder(logRotator( buildDiscarder(logRotator(
numToKeepStr: '10', numToKeepStr: '10',

View File

@ -1,3 +1,5 @@
library 'status-jenkins-lib@v1.6.5'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }
@ -18,13 +20,17 @@ pipeline {
disableConcurrentBuilds() disableConcurrentBuilds()
} }
stages { stages {
stage('Prep') { stage('Fetch') {
when { expression { !params.APK_URL } }
steps { script { steps { script {
if (params.PR_ID == null) { copyArtifacts(
error("PR_ID parameter not set!") 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 testrail_id \
-m \"new_ui_critical or new_ui_medium\" \ -m \"new_ui_critical or new_ui_medium\" \
-k \"${params.KEYWORD_EXPRESSION}\" \ -k \"${params.KEYWORD_EXPRESSION}\" \
--apk=${params.APK_NAME} --apk=${params.APK_URL ?: apk_path}
""" """
} }
} }

View File

@ -14,6 +14,10 @@ pipeline {
name: 'PR_ID', name: 'PR_ID',
description: 'ID of the Pull Request triggering this build.', 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( string(
name: 'KEYWORD_EXPRESSION', name: 'KEYWORD_EXPRESSION',
description: 'This will run tests which contain names that match the given string expression (Optional)', description: 'This will run tests which contain names that match the given string expression (Optional)',
@ -54,9 +58,11 @@ pipeline {
} }
stage('Fetch') { stage('Fetch') {
steps { script { /* WARNING: This copies the latest available artifact. */ when { expression { !params.APK_URL } }
steps { script {
copyArtifacts( copyArtifacts(
projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}", projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}",
/* WARNING: This copies the latest available artifact. */
selector: lastWithArtifacts(), selector: lastWithArtifacts(),
) )
apk_path = "${env.WORKSPACE}/${utils.findFile('result/*.apk')}" apk_path = "${env.WORKSPACE}/${utils.findFile('result/*.apk')}"
@ -119,7 +125,7 @@ pipeline {
--rerun_count=2 \ --rerun_count=2 \
--testrail_report=True \ --testrail_report=True \
-k \"${params.KEYWORD_EXPRESSION}\" \ -k \"${params.KEYWORD_EXPRESSION}\" \
--apk=${apk_path} \ --apk=${params.APK_URL ?: apk_path} \
--build=PR-${params.PR_ID}-${utils.timestamp()} \ --build=PR-${params.PR_ID}-${utils.timestamp()} \
--pr_number=${params.PR_ID} \ --pr_number=${params.PR_ID} \
${extraPytestOpts} ${extraPytestOpts}

View File

@ -1,3 +1,5 @@
library 'status-jenkins-lib@v1.6.5'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }

View File

@ -108,9 +108,9 @@ class BaseTestReport:
return url return url
@staticmethod @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/' \ 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): def get_sauce_final_screenshot_url(self, job_id):
return 'https://media.giphy.com/media/9M5jK4GXmD5o1irGrF/giphy.gif' return 'https://media.giphy.com/media/9M5jK4GXmD5o1irGrF/giphy.gif'

View File

@ -71,13 +71,11 @@ class GithubHtmlReport(BaseTestReport):
if not_executed_tests: if not_executed_tests:
html += "<li><a href=\"%s\">Rerun not executed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e( html += "<li><a href=\"%s\">Rerun not executed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e(
pr_id=pr_id, pr_id=pr_id,
apk_name=apk_name,
tr_case_ids=','.join([str(i) for i in tests])) tr_case_ids=','.join([str(i) for i in tests]))
if failed_tests: if failed_tests:
html += "<li><a href=\"%s\">Rerun failed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e( html += "<li><a href=\"%s\">Rerun failed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e(
pr_id=pr_id, pr_id=pr_id,
apk_name=apk_name,
tr_case_ids=','.join([str(test.testrail_case_id) for test in tests])) tr_case_ids=','.join([str(test.testrail_case_id) for test in tests]))
if not not_executed_tests: if not not_executed_tests: