Parameterized Jenkins build for rollback purposes.
Yes, I know, Jenkins is terrible. I don’t recommend using it. Use TravisCI, CircleCI or something like that.
Nonetheless. If u happen to use Jenkins for whatever reason, there are advantages to it. One of them is manually trigger-able and parameterized builds. With them, you can set up rollbacks to a specified git tag. When emergency hits (hope it’s not) you’ll need this.
Tick “This build is parameterized”:
In “Source Code Management” specify your git repo and click “Advanced…”
And there enter the following magic:
+refs/tags/$GIT_TAG:refs/remotes/origin/tags/$GIT_TAGHow I came up with this — trial+error+stackoverflow
Branches to build:
*/tags/$GIT_TAGAfter this, you’ll want to configure the rest of the build in your preferred fashion… whatever takes to actually build and deploy your repo… Click ‘Save’ and you are done.
Settings mentioned above are key to ensure successful checkout of a git tag you’ll specify in the following step.
- Click “Build with Parameters” in the top left menu. Enter git tag as a parameter. Click “Build” and profit!
Let me know how did this work for you! You should follow me up at @ksaitor and subscribe to this blog below.
P.S. Sign up to my newsletter
Hey, I rarely send these, but when I do, you'll be the first to know!