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: 'NETWORK',
|
|
|
|
description: 'Name of test network to use.',
|
|
|
|
defaultValue: 'ropsten',
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'TEST_MARKERS',
|
|
|
|
description: 'Marker expression for matching tests to run.',
|
|
|
|
defaultValue: 'critical or high',
|
|
|
|
)
|
|
|
|
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.',
|
|
|
|
)
|
2019-12-02 18:56:42 +00:00
|
|
|
string(
|
|
|
|
name: 'TR_CASE_IDS',
|
|
|
|
description: 'IDs of the TestRail case, separated by a comma. (Optional)',
|
|
|
|
)
|
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 */
|
|
|
|
def extraPytestOpts = ""
|
|
|
|
if (params.TR_CASE_IDS != "") {
|
|
|
|
extraPytestOpts = "--run_testrail_ids='${params.TR_CASE_IDS}'"
|
|
|
|
}
|
2019-10-10 17:38:50 +00:00
|
|
|
|
|
|
|
withCredentials([
|
|
|
|
string(
|
|
|
|
credentialsId: 'GIT_HUB_TOKEN',
|
|
|
|
variable: 'GIT_HUB_TOKEN'
|
|
|
|
),
|
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'test-rail-api',
|
|
|
|
usernameVariable: 'TESTRAIL_USER',
|
|
|
|
passwordVariable: 'TESTRAIL_PASS'
|
|
|
|
),
|
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'sauce-labs-api',
|
|
|
|
usernameVariable: 'SAUCE_USERNAME',
|
|
|
|
passwordVariable: 'SAUCE_ACCESS_KEY'
|
|
|
|
),
|
|
|
|
]) {
|
|
|
|
dir('test/appium/tests') {
|
|
|
|
sh """
|
|
|
|
python3 -m pytest -n24 \
|
|
|
|
--rerun_count=2 \
|
|
|
|
--testrail_report=True \
|
|
|
|
-m "${params.TEST_MARKERS}" \
|
|
|
|
--network=${params.NETWORK} \
|
|
|
|
--apk=${params.APK_NAME} \
|
|
|
|
--build=PR-${params.PR_ID} \
|
2019-12-02 18:56:42 +00:00
|
|
|
--pr_number=${params.PR_ID} \
|
|
|
|
${extraPytestOpts}
|
2019-10-10 17:38:50 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|