3 # Reference: https://docs.travis-ci.com/user/triggering-builds/
7 die
() { echo "${*}"; exit 1; }
9 [ "${*}" ] && echo >&2 -e "${*}\n"
10 echo "Usage: $0 REPO BRANCH [VAR=VAL]...
14 If you have the travis program installed then it will be called
15 to get an API token (you need to have done 'travis login --org'
16 in the past). Alternately you can explicity pass a token using
17 the TRAVIS_TOKEN environment variable. You can see your API
18 token at https://travis-ci.org/account/preferences.
22 By default 'api.travis-ci.org' is used for API calls. This can
23 be overridden by setting TRAVIS_HOST="api.travis-ci.com
"
27 Trigger build/test in self-hosted mode:
28 $0 REPO BRANCH DO_SELF_HOST=1
30 Trigger build/test with stop on soft failures:
31 $0 REPO BRANCH DO_HARD=1
33 Trigger build/test using regress mode on stepA:
34 $0 REPO BRANCH REGRESS=1 STEP=stepA
36 Trigger build/test using regress mode on all steps:
37 $0 REPO BRANCH REGRESS=1
43 TRAVIS_TOKEN
="${TRAVIS_TOKEN:-}" # default to travis program
44 TRAVIS_HOST
="${TRAVIS_HOST:-api.travis-ci.org}"
46 REPO
="${1}"; shift || usage
"REPO required"
47 BRANCH
="${1}"; shift || usage
"BRANCH required"
52 [ "${VARS}" ] && vars
="\"${VARS// /\", \"}\""
56 \"message\": \"Manual build. Settings: ${VARS}\",
57 \"branch\":\"${BRANCH}\",
66 if [ -z "${TRAVIS_TOKEN}" ]; then
67 which travis
>/dev
/null \
68 || die
"TRAVIS_TOKEN not set and travis command not found"
69 TRAVIS_TOKEN
="$(travis token --org --no-interactive)"
73 -H "Content-Type: application/json" \
74 -H "Accept: application/json" \
75 -H "Travis-API-Version: 3" \
76 -H "Authorization: token ${TRAVIS_TOKEN}" \
78 "https://${TRAVIS_HOST}/repo/${repo}/requests"