I have set up a Jenkins job using the multibranch plugin. Via my Jenkinsfile
, Jenkins executes the following steps:
- Build:
docker-compose build
- Test
- Push Git ref to internal Git repository
- Tag local Docker images with branch and build number
- Push local Docker images and tags to internal Nexus repository
- Calculate the deploy host name
- This is a Docker host that runs the new, deployed code
- My deploy code looks up the Git branch, and from that derives the Docker host that it should deploy to
- Start Ansible AWX deployment job
- AWX deploys the given images/tags/git refs to the requested deploy host
- Monitor AWX for successful job completion
Because of the multibranch plugin, this works to build and deploy from any branch. However now I would like to set up build promotion. By this I mean:
- I build branch
dev
. - Jenkins starts a job on branch
dev
. From here on, we'll call this "job 100". - Jenkins generates Docker tag
dev-100
, based on the Jenkins "job 100" - Jenkins deploys to Docker host "myapp.dev.mydomain".
- Up to here is described above
- I do more tests, for instance QA.
- I take some kind of action to "promote" Jenkins "job 100".
- "promote" means I want to reuse and re-tag the artifacts from "job 100". From here on, we'll say I'm promoting to
prod
. - THIS is the part I am asking how to do
- "promote" means I want to reuse and re-tag the artifacts from "job 100". From here on, we'll say I'm promoting to
- Jenkins starts job 5 on branch
prod
- Jenkins re-tags
dev-100
Docker images asprod-5
- The current multibranch approach builds a new
prod-5
Docker image instead of re-tagging the existingdev-100
Docker image
- The current multibranch approach builds a new
- Jenkins pushes
prod-build-5
to "myapp.prod.mydomain".
How can I promote and re-tag, either with the multibranch plugin, or via some other approach?
dev-100
image asprod-build-5
. You could also have only dev tests run on PR's, qa tests run ondevelop
branch and prod tagging on master/main branch.