Created
June 23, 2019 21:03
-
-
Save MGough/ddc637d1e244cc4ce1dcccbc7a55e2c4 to your computer and use it in GitHub Desktop.
Python testing jenkinsfile
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
// This is just a snippet, not a complete file | |
try { | |
stage('Unit Tests') { | |
// Build our base image | |
app = docker.build("our-service:PR-${BUILD_ID}") | |
// Build our test image passing our base image version and our test dockerfile | |
docker.build("our-service-test:PR-$BUILD_ID", "--build-arg BUILD_VERSION=PR-$BUILD_ID . -f test.Dockerfile") | |
// Run our tests! | |
// I've named our container, this will come in handy in a minute. | |
sh "docker run --name OUR_SERVICE_DEV_TEST_$BUILD_ID our-service-test:PR-$BUILD_ID " | |
} | |
} finally { | |
// We can retrieve our test results even though the container stopped! | |
sh "docker cp OUR_SERVICE_DEV_TEST_$BUILD_ID:/app/results.xml ." | |
junit 'results.xml' | |
// You may want to also do some image cleanup somewhere in your job depending on your Docker setup | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment