travis-citravis-ci-api

restarting builds with travis ci api


I can restart builds via the CLI by doing travis show branch -r user/project to get the build # and then by doing travis restart 1 -r user/project (where 1 is the build).

My question is... how can I do this via the Travis CI v3 API?


Solution

  • To do this you first need to get the repository.id by doing curl -L http://api.travis-ci.org/repos/username/project

    Then you can then get the various build #'ers by sending a GET request to https://api.travis-ci.org/repo/repository.id/builds (altho that'll return older builds as well, up to 25) and then you can restart by sending a POST request to https://api.travis-ci.org/build/build.id/restart with build.id={whatever the build.id is} as the POST data.

    See https://developer.travis-ci.com/resource/builds and https://developer.travis-ci.com/resource/build#restart for more info.