node library to access the Travis-CI API
var Travis = ;var travis =version: '2.0.0';// To access the Travis-CI Pro APIvar travis =version: '2.0.0'pro: true;// To access the Travis-CI Enterprise APIvar travis =version: '2.0.0'enterprise: '';// To set custom headersvar travis =version: '2.0.0'headers:'user-agent': 'My Custom User Agent';
Upgrade Notice (Migrating to 2.x)
Due to the expanding travis api, there were an increasing number of cases where a function could conceivably map to several http endpoints. To eliminate that complexity, and to ensure that the entire api could be exposed, the api has been rewritten to be a much more transparent layer on top of the http interface. Url path segments that are exposed as objects, unless they are followed by url parameters, in which case they are exposed as functions that consume those arguments. The function that makes the api call is now just http verbs (
For instance, to use this library to call
GET /repos/:owner_name/:name/builds/:id, you now do something like the following:
Many functions, such as
travis.accounts, require authenticating as a user.
Currently the only way to authenticate is to start with a github oauth token, request a travis access token, and authenticate with that.
As a convenience,
authenticate also accepts github tokens, or github credentials (which are only sent to github) and performs the necessary requests to acquire a travis access token. For example:
Pro Tip: Authentication is simply a convenience function that ensures your token has the required permissions, then appends your
access_tokento all subsequent requests. You can alternatively pass
access_tokento any request where permission is required.
Accounts calls require authentication.
Additional endpoints that have not be implemented yet:
Endpoints that exist, but are intended for brower flows:
// to get the info for a specific build, specify the build id// this is data used for pages such as://travis;
// to cancel a buildtraviscancel;
All hook calls require authentication.
Requests calls require authentication.
All user calls require authentication.
To install as a command line utility, just install globally via npm.
npm install -g travis-ci
The entire library is available via command line interface. While it uses subcommands, the api is the same as above.
travis-ci authenticate --username=pwmckenna --password=superSecret=># ortravis-ci auth github --github_token=ef7c329fb63479eb5be9719bb8b23162072bb20d=>
Pro Tip: Passing OAuth tokens or github credentials via the command line will leave them in your shell history for all to see. Please shell responsibly.
access_token above in all subsequent commands that require authentication, such as requesting the builds for this project:
travis-ci repos pwmckenna node-travis-ci builds --access_token=F7DlolJkD15isf4KEDuh_A=>