node library to access the Travis-CI API
Instantiation
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: 'https://travis.example.com'; // To set custom headersvar travis = version: '2.0.0' headers: 'user-agent': 'My Custom User Agent' ;
API
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 (get
/post
/etc).
For instance, to use this library to call GET /repos/:owner_name/:name/builds/:id
, you now do something like the following:
travis;
Authentication
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.
travisauthgithub;
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:
travis;
or
travis;
Pro Tip: Authentication is simply a convenience function that ensures your token has the required permissions, then appends your
access_token
to all subsequent requests. You can alternatively passaccess_token
to any request where permission is required.
Accounts
Accounts calls require authentication.
travisaccounts;
Authorization
travisauthgithub;
Additional endpoints that have not be implemented yet:
Endpoints that exist, but are intended for brower flows:
Branches
travisbranches;
Broadcasts
travisbroadcasts;
Builds
// to get the info for a specific build, specify the build id// this is data used for pages such as:// https://travis-ci.org/pwmckenna/node-travis-ci/builds/10380000travis;
// to cancel a buildtraviscancel;
Documentation
travisdocumentation;
Endpoints
travisendpoints;
travis;
Hooks
All hook calls require authentication.
travishooks;
travis;
Jobs
travis;
travisjobs;
Logs
travis;
Repos
travis;
travis;
traviskey;
travisbuilds;
Requests
Requests calls require authentication.
travisrequests
Users
All user calls require authentication.
travisusers;
travisuserspermissions;
travisuserssync;
CLI
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=> # or travis-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.
Use the 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=>