Is there a way to define the container where your entire pipeline stages and steps can run, from start to finish, without having to fire up a container each time you want a stage to run?
The reason for this is that I am running terraform, which requires a set of steps to execute before running the deploy (init, plan, apply). One could, of course, run each stage separately and call docker to run a container each time but that would be counter intuitive. Moreso data would be lost, unless you save terraform plan
output as an artifact, for example.. which is like scratching your left ear with the right hand, around your head.
I'd like to run the container at the top, then build each stage inside, without killing it.
CodePudding user response:
You can define your docker container in the agent section at the top-level of your Jenkinsfile :
pipeline {
agent {
docker {
image 'terraform-image'
}
}
stages {
....
}
}
Each stage will run in the same docker container and you will not lose your workspace between each stages.