Skip to content

Instantly share code, notes, and snippets.

@jirutka
Last active March 25, 2018 04:48
Show Gist options
  • Save jirutka/344c98dccce7cc851d0a to your computer and use it in GitHub Desktop.
Save jirutka/344c98dccce7cc851d0a to your computer and use it in GitHub Desktop.
This script triggers (re)build of the specified project on Travis CI.
#!/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
@hroncok
Copy link

hroncok commented Aug 13, 2015

I mean deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment