Manually trigger Travis CI builds on Pull Requests
March 11, 2017
This tutorial deals with pull requests on Github which have Travis CI integration.
The day before this was written, Travis CI experienced some issues as a result of which some builds didn’t complete. I had a pull-request open at the time, and the build for it was stuck at “waiting for build status”.
Usually, at that point you would perform a manual build. But if you don’t have access to the repository or the Travis instance, here’s how you can trigger a manual build.
-
Open a terminal, go to your project directory and
checkout
the branch from which you created the pull request.$ git checkout <some-cool-new-feature-branch>
-
Amend the last commit with:
$ git commit --amend
When
git
opens your commit message, save and quit. -
Force-push to your feature branch.
$ git push -f <your-fork> <some-cool-new-feature-branch>
- Voila! You should see a new build has been triggered.
This works because when you amend
your last commit, the commit-hash changes, which leads your CI to see it as a fresh commit for which it hasn’t run the build yet. Since commit-hashes take into account the timestamp of the commit, you will always get a different hash when you perfom a git commit --amend
.
A word of caution, though. This rewrites your git
history, so you have to be careful when you are doing this. Ideally, don’t do this on branches that others depend on / are based off of.
Originally seen on this comment.
This post used to be a part of my old blog, and was migrated here for legacy reasons.