Suppose I have a dockerized pipeline with multiple steps. The docker container is defined in the beginning of Jenkinsfile
:
pipeline {
agent {
docker {
image 'gradle:latest'
}
}
stages {
// multiple steps, all executed in 'gradle' container
}
post {
always {
sh 'git whatever-command' // will not work in 'gradle' container
}
}
}
I would like to execute some git
commands in a post-build action. The problem is that gradle
image does not have git
executable.
script.sh: line 1: git: command not found
How can I execute it on Docker host still using gradle
container for all other build steps? Of course I do not want to explicitly specify container for each step but that specific post-post action.