2

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
  • Jenkins starts job 5 on branch prod
  • Jenkins re-tags dev-100 Docker images as prod-5
    • The current multibranch approach builds a new prod-5 Docker image instead of re-tagging the existing dev-100 Docker image
  • 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?

1
  • I don't know what "I promote Jenkins job 100. " means. The answer to your question depends alot on other information like how do you do releases, what is your branch strategy etc. You could probably run a all the tests and if they all pass just retag your dev-100 image as prod-build-5. You could also have only dev tests run on PR's, qa tests run on develop branch and prod tagging on master/main branch.
    – Levi
    Mar 30 at 15:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.