2022-11-23 18:44:44 +00:00
|
|
|
library 'status-jenkins-lib@v1.6.3'
|
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',
|
|
|
|
)
|
2022-01-14 16:51:54 +00:00
|
|
|
/* Commented to use TEST_MARKERS values from job params
|
2019-10-10 17:38:50 +00:00
|
|
|
string(
|
|
|
|
name: 'TEST_MARKERS',
|
|
|
|
description: 'Marker expression for matching tests to run.',
|
2022-10-26 15:14:25 +00:00
|
|
|
defaultValue: 'new_ui_critical',
|
2022-01-14 16:51:54 +00:00
|
|
|
) */
|
2019-10-10 17:38:50 +00:00
|
|
|
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.',
|
|
|
|
)
|
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
|
|
|
)
|
2019-10-10 17:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2019-12-02 18:56:42 +00:00
|
|
|
stage('Checks') {
|
|
|
|
steps { script {
|
|
|
|
if (params.APK_NAME == null) { error("APK_NAME parameter not set!") }
|
|
|
|
if (params.PR_ID == null) { error("PR_ID parameter not set!") }
|
|
|
|
} }
|
|
|
|
}
|
2019-11-29 16:05:18 +00:00
|
|
|
stage('Setup') {
|
|
|
|
steps { script {
|
|
|
|
dir('test/appium') {
|
|
|
|
sh 'pip3 install --user -r requirements.txt'
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
2019-10-10 17:38:50 +00:00
|
|
|
stage('Test') {
|
|
|
|
steps { script {
|
|
|
|
currentBuild.displayName = "PR-${params.PR_ID}"
|
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 \
|
2022-05-04 15:40:13 +00:00
|
|
|
--numprocesses 9 \
|
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}\" \
|
2019-10-10 17:38:50 +00:00
|
|
|
--apk=${params.APK_NAME} \
|
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
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|