Some consultants at our office needed to be able to roll back a Jenkins project that deployed to staging and production sites in case of an issue. The project had been setup to allow for a typical git checkout and then ended up using a php build tool, phing, to essentially rsync up to the servers.
Turns out ‘Parameterized Builds’ was able to resolve this. It took just a few steps:
- Click ‘Configure’ on the project.
- Check ‘This build is parameterized’.
- Add a String Parameter with the name GIT_COMMIT and a default of ‘master’
- Under Git > Branches to build, add the parameter as $GIT_COMMIT
This allows you to specify the commit SHA for each release. If you need to roll back you just run it with the specified commit SHA. This can be configured to use git tags as well. Inspiration of this came from this post.