2023-05-16 11:06:37 +00:00
|
|
|
library 'status-jenkins-lib@v1.7.5'
|
2022-04-14 12:59:14 +00:00
|
|
|
|
2019-10-10 17:38:50 +00:00
|
|
|
pipeline {
|
|
|
|
|
2019-11-29 16:05:18 +00:00
|
|
|
agent { label 'linux' }
|
2019-10-10 17:38:50 +00:00
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(
|
|
|
|
name: 'BRANCH_NAME',
|
|
|
|
description: 'Name of the branch to checkout and build.',
|
|
|
|
defaultValue: 'develop',
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'PR_ID',
|
|
|
|
description: 'ID of the Pull Request triggering this build.',
|
|
|
|
)
|
2023-02-08 14:51:57 +00:00
|
|
|
string(
|
|
|
|
name: 'APK_URL',
|
|
|
|
description: 'Optional, set if job require APK to be downloaded from URL.',
|
|
|
|
)
|
2021-12-29 16:10:22 +00:00
|
|
|
string(
|
|
|
|
name: 'KEYWORD_EXPRESSION',
|
|
|
|
description: 'This will run tests which contain names that match the given string expression (Optional)',
|
|
|
|
defaultValue: '',
|
|
|
|
)
|
2019-12-02 18:56:42 +00:00
|
|
|
string(
|
|
|
|
name: 'TR_CASE_IDS',
|
2021-12-29 16:10:22 +00:00
|
|
|
description: 'IDs of the TestRail case, separated by a comma (Optional)',
|
2019-12-05 09:56:31 +00:00
|
|
|
defaultValue: '',
|
2019-12-02 18:56:42 +00:00
|
|
|
)
|
2023-02-06 10:58:22 +00:00
|
|
|
/* 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',
|
|
|
|
)
|
|
|
|
*/
|
2019-10-10 17:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2023-02-06 10:58:22 +00:00
|
|
|
stage('Prep') {
|
2019-12-02 18:56:42 +00:00
|
|
|
steps { script {
|
2023-02-06 10:58:22 +00:00
|
|
|
currentBuild.displayName = "PR-${params.PR_ID}"
|
|
|
|
if (params.PR_ID == null) {
|
|
|
|
error("PR_ID parameter not set!")
|
|
|
|
}
|
2019-12-02 18:56:42 +00:00
|
|
|
} }
|
|
|
|
}
|
2023-02-06 10:58:22 +00:00
|
|
|
|
|
|
|
stage('Fetch') {
|
2023-02-08 14:51:57 +00:00
|
|
|
when { expression { !params.APK_URL } }
|
|
|
|
steps { script {
|
2023-02-06 10:58:22 +00:00
|
|
|
copyArtifacts(
|
|
|
|
projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}",
|
2023-02-08 14:51:57 +00:00
|
|
|
/* WARNING: This copies the latest available artifact. */
|
2023-02-06 10:58:22 +00:00
|
|
|
selector: lastWithArtifacts(),
|
|
|
|
)
|
2023-02-07 12:07:23 +00:00
|
|
|
apk_path = "${env.WORKSPACE}/${utils.findFile('result/*.apk')}"
|
2023-02-06 10:58:22 +00:00
|
|
|
} }
|
|
|
|
}
|
|
|
|
|
2019-11-29 16:05:18 +00:00
|
|
|
stage('Setup') {
|
|
|
|
steps { script {
|
|
|
|
dir('test/appium') {
|
|
|
|
sh 'pip3 install --user -r requirements.txt'
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
2023-02-06 10:58:22 +00:00
|
|
|
|
2019-10-10 17:38:50 +00:00
|
|
|
stage('Test') {
|
|
|
|
steps { script {
|
2019-12-02 18:56:42 +00:00
|
|
|
/* for managing optional arguments */
|
2019-12-05 09:56:31 +00:00
|
|
|
def extraPytestOpts = ''
|
|
|
|
if (params.TR_CASE_IDS != '') {
|
2019-12-02 18:56:42 +00:00
|
|
|
extraPytestOpts = "--run_testrail_ids='${params.TR_CASE_IDS}'"
|
2022-05-17 02:52:15 +00:00
|
|
|
} else {
|
|
|
|
extraPytestOpts = "-m \"${params.TEST_MARKERS}\""
|
2019-12-02 18:56:42 +00:00
|
|
|
}
|
2019-10-10 17:38:50 +00:00
|
|
|
|
|
|
|
withCredentials([
|
2020-02-24 13:46:27 +00:00
|
|
|
usernamePassword(
|
2021-04-14 11:50:22 +00:00
|
|
|
credentialsId: 'status-im-auto',
|
2020-02-24 13:46:27 +00:00
|
|
|
usernameVariable: 'GIT_HUB_USER', /* ignored */
|
|
|
|
passwordVariable: 'GIT_HUB_TOKEN'
|
2019-10-10 17:38:50 +00:00
|
|
|
),
|
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'test-rail-api',
|
|
|
|
usernameVariable: 'TESTRAIL_USER',
|
|
|
|
passwordVariable: 'TESTRAIL_PASS'
|
|
|
|
),
|
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'sauce-labs-api',
|
|
|
|
usernameVariable: 'SAUCE_USERNAME',
|
|
|
|
passwordVariable: 'SAUCE_ACCESS_KEY'
|
|
|
|
),
|
2020-02-24 11:30:45 +00:00
|
|
|
string(
|
|
|
|
credentialsId: 'etherscan-api-key',
|
|
|
|
variable: 'ETHERSCAN_API_KEY'
|
|
|
|
),
|
2020-12-04 17:27:21 +00:00
|
|
|
string(
|
|
|
|
credentialsId: 'infura-e2e-token',
|
|
|
|
variable: 'WEB3_INFURA_PROJECT_ID'
|
|
|
|
),
|
2022-03-07 21:17:39 +00:00
|
|
|
file(
|
|
|
|
credentialsId: "mobile-tests-eth-accounts",
|
|
|
|
variable: 'TEST_ETH_ACCOUNTS_FILE'
|
|
|
|
),
|
2019-10-10 17:38:50 +00:00
|
|
|
]) {
|
|
|
|
dir('test/appium/tests') {
|
2022-03-07 21:17:39 +00:00
|
|
|
/* Provide Eth test account secrets. */
|
|
|
|
sh 'cp -f $TEST_ETH_ACCOUNTS_FILE users.py'
|
2019-10-10 17:38:50 +00:00
|
|
|
sh """
|
2020-11-09 19:30:22 +00:00
|
|
|
python3 -m pytest \
|
2023-01-18 13:06:05 +00:00
|
|
|
--numprocesses 4 \
|
2019-10-10 17:38:50 +00:00
|
|
|
--rerun_count=2 \
|
|
|
|
--testrail_report=True \
|
2021-12-29 16:10:22 +00:00
|
|
|
-k \"${params.KEYWORD_EXPRESSION}\" \
|
2023-02-08 14:51:57 +00:00
|
|
|
--apk=${params.APK_URL ?: apk_path} \
|
2022-04-14 12:59:14 +00:00
|
|
|
--build=PR-${params.PR_ID}-${utils.timestamp()} \
|
2019-12-02 18:56:42 +00:00
|
|
|
--pr_number=${params.PR_ID} \
|
|
|
|
${extraPytestOpts}
|
2019-10-10 17:38:50 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
}
|
2023-02-08 17:01:24 +00:00
|
|
|
post {
|
|
|
|
cleanup {
|
|
|
|
sh 'make purge'
|
|
|
|
}
|
|
|
|
}
|
2019-10-10 17:38:50 +00:00
|
|
|
}
|