diff --git a/Jenkinsfile b/Jenkinsfile index 624d5cf4..76287fca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,19 @@ -def runPlaywrightTests(resultDir) { - sh 'mkdir -p ./test-results' - sh """ - PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project webkit --project iphoneSE --reporter=junit || true - """ - junit 'results.xml' - sh """ - mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/ - mkdir -p ./test-results - mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/ - """ +def runPlaywrightTests(resultDir, browser, grep) { + try { + timeout(20) { + sh 'mkdir -p ./test-results' + sh """ + PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project $browser --reporter=junit --workers 10 --grep "$grep"|| true + """ + } + } finally { + junit 'results.xml' + sh """ + mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/ + mkdir -p ./test-results + mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/ + """ + } } def withEnvFile(envfile, Closure cb) { @@ -19,9 +24,11 @@ def withEnvFile(envfile, Closure cb) { } pipeline { - agent { label 'crawler-autoconsent' } + agent { label 'autoconsent-crawler' } parameters { string(name: 'TEST_RESULT_ROOT', defaultValue: '/mnt/efs/users/smacbeth/autoconsent/ci', description: 'Where test results and configuration are stored') + choice(name: 'BROWSER', choices: ['webkit', 'iphoneSE', 'chrome', 'firefox'], description: 'Browser') + string(name: 'GREP', defaultValue: '', description: 'filter for tests matching a specific string') } environment { NODENV_VERSION = "14.15.4" @@ -41,13 +48,16 @@ pipeline { npm ci npx playwright install webkit ''' + script { + currentBuild.description = "${params.BROWSER} - ${params.GREP}" + } } } stage('Test: DE') { steps { withEnvFile("${params.TEST_RESULT_ROOT}/de.env") { - runPlaywrightTests(params.TEST_RESULT_ROOT) + runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP) } } } @@ -55,7 +65,7 @@ pipeline { stage('Test: US') { steps { withEnvFile("${params.TEST_RESULT_ROOT}/us.env") { - runPlaywrightTests(params.TEST_RESULT_ROOT) + runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP) } } } @@ -63,7 +73,7 @@ pipeline { stage('Test: GB') { steps { withEnvFile("${params.TEST_RESULT_ROOT}/gb.env") { - runPlaywrightTests(params.TEST_RESULT_ROOT) + runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP) } } } @@ -71,7 +81,7 @@ pipeline { stage('Test: FR') { steps { withEnvFile("${params.TEST_RESULT_ROOT}/fr.env") { - runPlaywrightTests(params.TEST_RESULT_ROOT) + runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP) } } }