Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created April 24, 2016 12:17
Show Gist options
  • Save Voronenko/45a1f1b6cc6d152b4a3173420c1507b1 to your computer and use it in GitHub Desktop.
Save Voronenko/45a1f1b6cc6d152b4a3173420c1507b1 to your computer and use it in GitHub Desktop.
travis build trigger
#!/bin/bash
## References for triggering builds using Travis CI API
# https://docs.travis-ci.com/user/triggering-builds
# If any commands fail, we want the shell script to exit immediately.
set -e
# Verify input params
if [ "$#" -ne 3 ]; then
echo "Usage: travis_build_trigger.sh [repo] [branch] [travis token]"
exit 1
fi
# Set variables
repo=$1
branch=$2
token=$3
# Payload for HTTP POST request
body='{
"request": {
"branch":"'$branch'"
}
}'
# Trigger build for repo.
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $token" \
-d "$body" \
https://api.travis-ci.org/repo/${repo}/requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment