status-mobile/ci/tests/Jenkinsfile.e2e-prs
Jakub Sokołowski 8ebad39c25
ci: add cleanup step to all e2e Jenkins jobs
Otherwise we get multiple APKs in the `results` folder.
```
admin@linux-01.he-eu-hel1.ci.devel:/home/jenkins/workspace/status-mobile/e2e/status-app-prs % ls -l result
total 502236
-rw-r--r-- 1 jenkins jenkins 57334087 Feb  7 10:25 StatusIm-Mobile-230207-101618-991339-pr14988-x86.apk
-rw-r--r-- 1 jenkins jenkins 57080127 Feb  7 13:18 StatusIm-Mobile-230207-131114-098c05-pr14977-x86.apk
-rw-r--r-- 1 jenkins jenkins 57088322 Feb  7 14:19 StatusIm-Mobile-230207-141155-05cc4c-pr15002-x86.apk
...
```
And `utils.findFile()` just pick the first one alphabeticlly.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2023-02-08 18:26:45 +01:00

138 lines
3.7 KiB
Plaintext

library 'status-jenkins-lib@v1.6.5'
pipeline {
agent { label 'linux' }
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.',
)
string(
name: 'KEYWORD_EXPRESSION',
description: 'This will run tests which contain names that match the given string expression (Optional)',
defaultValue: '',
)
string(
name: 'TR_CASE_IDS',
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 {
disableConcurrentBuilds()
}
stages {
stage('Prep') {
steps { script {
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.WORKSPACE}/${utils.findFile('result/*.apk')}"
} }
}
stage('Setup') {
steps { script {
dir('test/appium') {
sh 'pip3 install --user -r requirements.txt'
}
} }
}
stage('Test') {
steps { script {
/* for managing optional arguments */
def extraPytestOpts = ''
if (params.TR_CASE_IDS != '') {
extraPytestOpts = "--run_testrail_ids='${params.TR_CASE_IDS}'"
} else {
extraPytestOpts = "-m \"${params.TEST_MARKERS}\""
}
withCredentials([
usernamePassword(
credentialsId: 'status-im-auto',
usernameVariable: 'GIT_HUB_USER', /* ignored */
passwordVariable: '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'
),
string(
credentialsId: 'etherscan-api-key',
variable: 'ETHERSCAN_API_KEY'
),
string(
credentialsId: 'infura-e2e-token',
variable: 'WEB3_INFURA_PROJECT_ID'
),
file(
credentialsId: "mobile-tests-eth-accounts",
variable: 'TEST_ETH_ACCOUNTS_FILE'
),
]) {
dir('test/appium/tests') {
/* Provide Eth test account secrets. */
sh 'cp -f $TEST_ETH_ACCOUNTS_FILE users.py'
sh """
python3 -m pytest \
--numprocesses 4 \
--rerun_count=2 \
--testrail_report=True \
-k \"${params.KEYWORD_EXPRESSION}\" \
--apk=${apk_path} \
--build=PR-${params.PR_ID}-${utils.timestamp()} \
--pr_number=${params.PR_ID} \
${extraPytestOpts}
"""
}
}
} }
}
}
post {
cleanup {
sh 'make purge'
}
}
}