Trigger a build on TravisCI via Travis API v3.
Install the Helper with the following command:
npm install --save lyne-helper-trigger-travis
Require the module:
const triggerTravis = require('lyne-helper-trigger-travis');
Build up your config:
const config = {
branchName: 'BRANCH_NAME',
message: 'MESSAGE',
travisToken: 'TRAVIS_TOKEN',
travisUrl: 'TRAVIS_URL'
};
The module has a single method which returns a promise. You can use it as follows:
triggerTravis(config)
.then((data) => {
if (data) {
console.log(data);
}
})
.catch((err) => {
console.log(err);
});
branchName
: the branch on which the job should trigger
message
: the message which acts as the commit message for the build
travisToken
: the access token from your travis account
travisUrl
: the url to the travis project.
If you use travis.com, please use https://api.travis-ci.com/repo/{slug|id}/requests.
Example for a project on travis.com with the user name lyne-design-system
and the repo name lyne-design-tokens
: https://api.travis-ci.com/repo/lyne-design-system%2Flyne-design-tokens/requests
Please follow the Conventional Commits specification to make sure we can automatically determine the next release version if necessary.
The package is automatically versioned and published to npm after successfull build on travis.
If there is something wrong or weird with the Travis API, you can try to trigger a Travis Job directly via CLI with the following command:
body='{
"request": {
"branch":"master"
}
}'
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token TRAVIS-TOKEN-HERE" \
-d "$body" \
https://api.travis-ci.com/repo/lyne-design-system%2Flyne-documentation/requests