When our browser-based tests fail, we will take a screenshot in the browser window to better illustrate the problem. However, I do not understand how to archive them in my pipeline, because the pipeline stops after a failure. The same for junit.xml, I would also like to use it in cases of errors.
I checked, screenshots are created and saved correctly.
My definition is as follows (irrelevant things are mostly trimmed):
node {
stage('Build docker container') {
checkout([$class: 'GitSCM', ...])
sh "docker build -t webapp ."
}
stage('test build') {
sh "mkdir -p rspec screenshots"
sh "docker run -v /var/jenkins_home/workspace/webapp/rspec/junit.xml:/myapp/junit.xml -v /var/jenkins_home/workspace/webapp/screenshots:/myapp/tmp/capybara -v webapp bundle exec rspec"
}
stage('Results') {
junit 'rspec/junit*.xml'
archive 'screenshots/*'
}
}
source
share