Manually trigger Travis CI builds on Pull Requests

2017-03-11

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
  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
  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.

Pradeep CE

Pradeep CE

I am the author of this blog. I enjoy coding, learning new things and solving problems. This blog is where I share my learnings on running a one-person software business, software development, and life.

Thanks for reading!