Last active
March 25, 2018 04:48
-
-
Save jirutka/344c98dccce7cc851d0a to your computer and use it in GitHub Desktop.
This script triggers (re)build of the specified project on Travis CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script triggers (re)build of the specified project on Travis CI. | |
# | |
# It expects Travis token to be set in environment variable TRAVIS_TOKEN. | |
# To get a token, run: travis token. | |
# | |
# Usage: | |
# travis-build-dependent <REPO_SLUG> [<BRANCH>] | |
# | |
# REPO_SLUG the repository to build, typically username/project-name. | |
# BRANCH the branch to build (default is 'master'). | |
message="Triggered by successful build of $TRAVIS_REPO_SLUG" | |
repo_slug=$1 | |
branch=${2:-master} | |
body="{ | |
'request': { | |
'message': '$message', | |
'branch': '$branch' | |
} | |
}" | |
echo "Triggering build of $repo_slug branch $branch on Travis." | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-H "Accept: application/json" \ | |
-H "Travis-API-Version: 3" \ | |
-H "Authorization: token $TRAVIS_TOKEN" \ | |
-d "${body//\'/\"}" \ | |
https://api.travis-ci.org/repo/${repo_slug/\//%2F}/requests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jirutka I was thinking about personal token stored in team repo, but as long as you trust your mates and their security, it should be fine. Worst case, somebody breaks your Travis setup, should not be a big feal.