Created
June 10, 2020 07:34
-
-
Save mgrybyk/0e70cafe30f222e2593d0eedbfe23677 to your computer and use it in GitHub Desktop.
WebdriverIO Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
options { | |
timeout(time: 20, unit: 'MINUTES') | |
buildDiscarder(logRotator(numToKeepStr: '300')) | |
} | |
parameters { | |
booleanParam( | |
name: 'RUN_CHROME', | |
defaultValue: true, | |
description: 'run tests in chrome browser') | |
booleanParam( | |
name: 'RUN_FIREFOX', | |
defaultValue: true, | |
description: 'run tests in firefox browser') | |
booleanParam( | |
name: 'RUN_MOBILE_EMULATION', | |
defaultValue: true, | |
description: 'run tests in chrome browser in mobile emulation mode') | |
} | |
stages { | |
stage('Prepare') { | |
steps { | |
sh 'mkdir -p report/allure-results' | |
script { | |
currentBuild.displayName = "$currentBuild.displayName" | |
} | |
} | |
} | |
stage("Run Tests") { | |
parallel { | |
stage('chrome') { | |
when { | |
expression { RUN_CHROME == 'true' } | |
} | |
steps { | |
script { | |
runTests('chrome', false) | |
} | |
} | |
} | |
stage('firefox') { | |
when { | |
expression { RUN_FIREFOX == 'true' } | |
} | |
steps { | |
runTests('firefox', false) | |
} | |
} | |
stage('mobileEmulation') { | |
when { | |
expression { RUN_MOBILE_EMULATION == 'true' } | |
} | |
steps { | |
runTests('chrome', true) | |
} | |
} | |
} | |
post { | |
always { | |
allure includeProperties: true, jdk: '', properties: [[ | |
key: 'allure.tests.management.pattern', | |
value: 'https://mytms/%s'], [ | |
key: 'allure.issues.tracker.pattern', | |
value: 'https://myjira/browse/%s']], | |
results: [[path: 'report/allure-results/']] | |
archiveArtifacts allowEmptyArchive: true, artifacts: "report/allure-results/" | |
} | |
} | |
} | |
} | |
post { | |
always { | |
cleanWs() | |
} | |
} | |
} | |
def runTests(browser, mobileEmulation) { | |
docker.image("atools/${browser}-headless:java8-node12-latest").inside('-u root:root') { | |
sh "cd /app && npm install" | |
// run tests | |
try { | |
sh "cd /app && MOBILE_EMULATION=${mobileEmulation} npm run ${browser}" | |
} catch (error) { | |
throw error | |
} finally { | |
// allure results | |
sh "cp /app/report/allure-results/*.* $WORKSPACE/report/allure-results/" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
options { | |
timeout(time: 20, unit: 'MINUTES') | |
buildDiscarder(logRotator(numToKeepStr: '300')) | |
} | |
parameters { | |
booleanParam( | |
name: 'RUN_CHROME', | |
defaultValue: true, | |
description: 'run tests in chrome browser') | |
booleanParam( | |
name: 'RUN_FIREFOX', | |
defaultValue: true, | |
description: 'run tests in firefox browser') | |
booleanParam( | |
name: 'RUN_MOBILE_EMULATION', | |
defaultValue: true, | |
description: 'run tests in chrome browser in mobile emulation mode') | |
} | |
stages { | |
stage('Prepare') { | |
steps { | |
sh 'mkdir -p report/allure-results' | |
script { | |
currentBuild.displayName = "$currentBuild.displayName" | |
} | |
} | |
} | |
stage("Build Docker Images") { | |
parallel { | |
stage('chrome') { | |
steps { | |
script { | |
docker.build('e2e-standalone:chrome', '--build-arg BROWSER_NAME=chrome -f ./ci/docker/standalone.Dockerfile .') | |
} | |
} | |
} | |
stage('firefox') { | |
steps { | |
script { | |
docker.build('e2e-standalone:firefox', '--build-arg BROWSER_NAME=firefox -f ./ci/docker/standalone.Dockerfile .') | |
} | |
} | |
} | |
} | |
} | |
stage("Run Tests") { | |
parallel { | |
stage('chrome') { | |
when { | |
expression { RUN_CHROME == 'true' } | |
} | |
steps { | |
script { | |
runTests('chrome', false) | |
} | |
} | |
} | |
stage('firefox') { | |
when { | |
expression { RUN_FIREFOX == 'true' } | |
} | |
steps { | |
runTests('firefox', false) | |
} | |
} | |
stage('mobileEmulation') { | |
when { | |
expression { RUN_MOBILE_EMULATION == 'true' } | |
} | |
steps { | |
runTests('chrome', true) | |
} | |
} | |
} | |
post { | |
always { | |
allure includeProperties: true, jdk: '', properties: [[ | |
key: 'allure.tests.management.pattern', | |
value: 'https://mytms/%s'], [ | |
key: 'allure.issues.tracker.pattern', | |
value: 'https://myjira/browse/%s']], | |
results: [[path: 'report/allure-results/']] | |
archiveArtifacts allowEmptyArchive: true, artifacts: "report/allure-results/" | |
} | |
} | |
} | |
} | |
post { | |
always { | |
cleanWs() | |
} | |
} | |
} | |
def runTests(browser, mobileEmulation) { | |
docker.image("e2e-standalone:${browser}").inside('-u root:root') { | |
// run tests | |
try { | |
sh "cd /app && MOBILE_EMULATION=${mobileEmulation} npm run ${browser}" | |
} catch (error) { | |
throw error | |
} finally { | |
// allure results | |
sh "cp /app/report/allure-results/*.* $WORKSPACE/report/allure-results/" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG BROWSER_NAME=chrome | |
FROM atools/${BROWSER_NAME}-headless:java8-node12-latest | |
USER root | |
ADD ./ /app/ | |
WORKDIR /app | |
RUN npm install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment