Closed dggadhia closed 1 year ago
Yeah, the doc is from Node.js port of playwright, you have to replace the steps with your own code. We don't have a good guide for that at the moment, try asking for examples in our slack channel for now.
have already raised in slack channel but no help as of now. dg gadhia 4:44 PM Any one has integrated Playwright+Cucumber+Java tests with Jenkins?.Is it working?
It is working, I am using the playwright docker image, below code is put in a Jenkins file, but it is specific to some extend with my project and company.
Try to play around and replace stuff where needed to suit you project:
pipeline {
agent { docker { image mcr.microsoft.com/playwright/java:v1.26.0-focal } }
parameters {
string( name: 'TAG', defaultValue: '@EndToEndTests', description: 'Place a tag in order to run a subset of scenarios')
choice( name: 'ENV_CONFIG', choices: ['configQA', 'configDev'], description: "Select configuration environment file")
}
environment {
PLAYWRIGHT_JAVA_SRC = "${env.WORKSPACE}/e2e/src/main/java:${env.WORKSPACE}/e2e/src/test/java"
}
stages {
stage('e2e-tests') {
steps {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL} with working directory ${env.WORKSPACE}"
echo "Tag: ${params.TAG} - Config: ${params.ENV_CONFIG}"
checkout scm
catchError(message: 'Tests failed: review pipeline logs',
buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
dir("e2e"){
sh 'mvn exec:java -e "-Dexec.mainClass=com.microsoft.playwright.CLI" "-Dexec.args=install chrome"'
sh "mvn test -DargLine=-Dcucumber.filter.tags=${params.TAG} -DcfgFile=${params.ENV_CONFIG}"
}
}
publishHTML (target : [
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'e2e/target/cucumber-reports',
reportFiles: 'index.html',
reportName: 'Cucumber Test Run Report',
reportTitles: 'Cucumber Test Run Report'
]
)
}
}
}
post {
always {
junit 'e2e/target/cucumber-reports/**/*.xml'
}
unstable {
archiveArtifacts '**/*.zip'
}
}
}
Closing per the response above, feel free to open a new issue if it doesn't work.
I tried these steps but not working, not clear as what needs to be done.