According to Jenkins Pipeline Docs, I should be able to use pipeline steps while working with Docker. However, "archiveArtifacts" does not appear to work:
def container = docker.image("some_image")
container.inside {
sh 'date > /tmp/test.txt'
sh 'cat /tmp/test.txt' //works, shows file
def fileContents = readFile '/tmp/test.txt' //works
echo "Contents: ${fileContents}" //works, shows file
archiveArtifacts '/tmp/*.txt' //FAILS
}
"ERROR: No artifacts found that match the file pattern "/tmp/*.txt". Configuration error?".
Things I've tried:
- Adding sync and sleep(5) before the archive step in case this is a file sync issue.
- Trying to archive '/*' and '*' in case it's running on the host (same error).
Any suggestions on archiving files generated in a Docker container?
PS: I opened a bug report... It looks like archiveArtifacts will only work on files in $WORKSPACE in docker containers.