|
| 1 | +#!/usr/bin/env groovy |
| 2 | + |
| 3 | + |
| 4 | +pipeline { |
| 5 | + |
| 6 | + agent { label 'linux' } |
| 7 | + |
| 8 | + parameters { |
| 9 | + string( |
| 10 | + name: 'APK_BUILD_NUMBER', |
| 11 | + description: 'platform/e2e build number for apk artifact', |
| 12 | + ) |
| 13 | + string( |
| 14 | + name: 'KEYWORD_EXPRESSION', |
| 15 | + description: 'This will run tests which contain names that match the given string expression (Optional)', |
| 16 | + defaultValue: '', |
| 17 | + ) |
| 18 | + string( |
| 19 | + name: 'BRANCH', |
| 20 | + description: 'Name of the branch to checkout and build.', |
| 21 | + defaultValue: 'develop', |
| 22 | + ) |
| 23 | + string( |
| 24 | + name: 'TR_CASE_IDS', |
| 25 | + description: 'IDs of the TestRail case, separated by a comma (Optional)', |
| 26 | + defaultValue: '', |
| 27 | + ) |
| 28 | + } |
| 29 | + |
| 30 | + options { |
| 31 | + disableConcurrentBuilds() |
| 32 | + } |
| 33 | + |
| 34 | + stages { |
| 35 | + stage('Fetch') { |
| 36 | + steps { script { |
| 37 | + copyArtifacts( |
| 38 | + projectName: "status-mobile/platforms/android-e2e", |
| 39 | + filter: 'result/*-x86.apk', |
| 40 | + selector: specific(env.APK_BUILD_NUMBER), |
| 41 | + ) |
| 42 | + apk_path = "${env.WORKSPACE}/${utils.findFile('result/*-x86.apk')}" |
| 43 | + |
| 44 | + } } |
| 45 | + } |
| 46 | + |
| 47 | + stage('Setup') { |
| 48 | + steps { script { |
| 49 | + dir('test/appium') { |
| 50 | + sh 'pip3 install --user -r requirements.txt' |
| 51 | + } |
| 52 | + } } |
| 53 | + } |
| 54 | + |
| 55 | + stage('Test') { |
| 56 | + steps { |
| 57 | + withCredentials([ |
| 58 | + usernamePassword( |
| 59 | + credentialsId: 'test-rail-api', |
| 60 | + usernameVariable: 'TESTRAIL_USER', |
| 61 | + passwordVariable: 'TESTRAIL_PASS' |
| 62 | + ), |
| 63 | + usernamePassword( |
| 64 | + credentialsId: 'sauce-labs-api', |
| 65 | + usernameVariable: 'SAUCE_USERNAME', |
| 66 | + passwordVariable: 'SAUCE_ACCESS_KEY' |
| 67 | + ), |
| 68 | + string( |
| 69 | + credentialsId: 'etherscan-api-key', |
| 70 | + variable: 'ETHERSCAN_API_KEY' |
| 71 | + ), |
| 72 | + string( |
| 73 | + credentialsId: 'infura-e2e-token', |
| 74 | + variable: 'WEB3_INFURA_PROJECT_ID' |
| 75 | + ), |
| 76 | + file( |
| 77 | + credentialsId: "mobile-tests-eth-accounts", |
| 78 | + variable: 'TEST_ETH_ACCOUNTS_FILE' |
| 79 | + ), |
| 80 | + ]) { |
| 81 | + dir('test/appium/tests') { |
| 82 | + /* Provide Eth test accounts secrets. */ |
| 83 | + sh 'cp -f $TEST_ETH_ACCOUNTS_FILE users.py' |
| 84 | + sh """ |
| 85 | + python3 -m pytest \ |
| 86 | + --numprocesses 6 \ |
| 87 | + --rerun_count=2 \ |
| 88 | + --testrail_report=True \ |
| 89 | + -m testrail_id \ |
| 90 | + -m \"new_ui_critical or new_ui_medium\" \ |
| 91 | + -k \"${params.KEYWORD_EXPRESSION}\" \ |
| 92 | + --apk=${params.APK_URL ?: apk_path} |
| 93 | + """ |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + post { |
| 101 | + always { |
| 102 | + script { |
| 103 | + sauce('sauce-labs-cred') { |
| 104 | + saucePublisher() |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + success { |
| 109 | + script { |
| 110 | + junit( |
| 111 | + testDataPublishers: [[$class: 'SauceOnDemandReportPublisher', jobVisibility: 'public']], |
| 112 | + testResults: 'test/appium/tests/*.xml' |
| 113 | + ) |
| 114 | + } |
| 115 | + } |
| 116 | + cleanup { |
| 117 | + sh 'make purge' |
| 118 | + } |
| 119 | + } |
| 120 | +} |
0 commit comments