Pradeep CE

Passionate programmer, web developer, motorcycle enthusiast, book lover, aspiring writer and wanna-be entrepreneur :)

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.

  1. 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>
  2. Amend the last commit with:

    $ git commit --amend

    When git opens your commit message, save and quit.

  3. Force-push to your feature branch.

    $ git push -f <your-fork> <some-cool-new-feature-branch>
  4. 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.


The views and opinions expressed on this site are my own. They do not reflect the views or policies of any employer or client, past or present.

🐞 Found a bug? Slow to load? Hard to navigate? Doesn't look quite right? This blog is still brand-new, so please let me know! 🙏
Pradeep CE | Copyright © 2020 | pradeepcep@gmail.com | v2.0