I have a jenkinsfile that uses a dockerfile - and am interested in how I can copy a file from the docker image to the jenkins workspace. Specifically - I am generating an HTML report on the docker image that I'd like to have published by the jenkins job.
For example, if I generate a file called test.html in the /app/ directory of the docker image - how do I copy it to the jenkins workspace so I can publish it.
Sample Jenkinsfile below:
node ('ondemand') {
try {
stage "build"
checkout scm
def customImage = docker.build("docker-image:${env.BUILD_ID}", "-f ./docker-image/Dockerfile .")
stage "test copying files"
customImage.inside('-u root') {
sh 'touch /app/test.html && ls' // can see that test.html is generated
}
}