Skip to content

Instantly share code, notes, and snippets.

@simonmcc
Last active February 5, 2019 23:53
Show Gist options
  • Save simonmcc/29071aade32012f186ed8273ff1442ed to your computer and use it in GitHub Desktop.
Save simonmcc/29071aade32012f186ed8273ff1442ed to your computer and use it in GitHub Desktop.
Running a Jenkins post stage in a docker container
pipeline {
agent none
stages {
stage('Step1'){
agent { docker { image 'simonmcc/hashicorp-pipeline:latest' } }
steps {
echo "Hello from Step1"
}
}
stage('Stage2') {
steps {
script {
echo "this is a scripted fragment"
docker.image("simonmcc/hashicorp-pipeline:latest").inside {
sh 'ls'
}
}
}
}
}
post {
always {
echo "post-always"
script {
echo "this is a scripted fragment"
docker.image("simonmcc/hashicorp-pipeline:latest").inside {
sh 'ls'
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment