17
17
# To obtain a Travis auth token, follow the instructions on:
18
18
# https://docs.travis-ci.com/user/triggering-builds/
19
19
#
20
+ # - TRPL_JA_PDF_GITHUB_ORG (Optional):
21
+ # The GitHub organization or user name of trpl-ja-pdf, default to
22
+ # `rust-lanu-ja`. To override it, define this variable at
23
+ # CirildCI's web console or in circle.yml.
24
+ #
20
25
# - TRPL_JA_PDF_GITHUB_REPO (Optional):
21
26
# The GitHub repository name of trpl-ja-pdf, default to
22
27
# `trpl-ja-pdf`. To override it, define this variable at
23
28
# CircleCI's web console or in circle.yml.
24
29
#
25
- # - TRPL_JA_PDF_GITHUB_ORG (Optional):
26
- # The GitHub organization or user name of trpl-ja-pdf, default to
27
- # `rust-lanu-ja`. To override it, define this variable at
28
- # CirildCI's web console or in circle.yml.
30
+ # - TRPL_JA_PDF_GITHUB_BRANCH (Optional):
31
+ # The GitHub branch of trpl-ja-pdf, default to `master`. To
32
+ # override it, define this variable at CircleCI's web console or
33
+ # in circle.yml.
29
34
30
35
set -e
31
36
@@ -36,37 +41,41 @@ if [ -z "${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN+x}" ]; then
36
41
exit 1
37
42
fi
38
43
39
- GITHUB_REPO=${TRPL_JA_PDF_GITHUB_REPO:- tarpl-ja-pdf}
40
44
GITHUB_ORG=${TRPL_JA_PDF_GITHUB_ORG:- rust-lang-ja}
45
+ GITHUB_REPO=${TRPL_JA_PDF_GITHUB_REPO:- trpl-ja-pdf}
46
+ GITHUB_BRANCH=${TRPL_JA_PDF_GITHUB_BRANCH:- master}
41
47
42
48
set -u
43
49
44
50
# Get the revision of current branch.
45
51
REVISION=$( git rev-parse --short HEAD)
46
52
47
- BUILD_PARAMS=' {
53
+ BUILD_PARAMS=$( cat << EOF
54
+ {
48
55
"request": {
49
- "branch": "master"
56
+ "branch": "${GITHUB_BRANCH} ",
50
57
"message": "automatic build triggered by trpl-ja commit ${REVISION} "
51
58
}
52
- }'
59
+ }
60
+ EOF
61
+ )
53
62
54
- echo " Triggering a build on Travis CI for ${GITHUB_ORG} /${GITHUB_REPO} ."
63
+ echo " Triggering a build on Travis CI for ${GITHUB_BRANCH} branch of ${ GITHUB_ORG} /${GITHUB_REPO} ."
55
64
56
- set +e
57
- curl -s -X POST \
65
+ HTTP_RESPONSE= $( curl -s -X POST \
66
+ -w " - HTTP Status %{http_code} " \
58
67
-H " Content-Type: application/json" \
59
68
-H " Accept: application/json" \
60
69
-H " Travis-API-Version: 3" \
61
70
-H " Authorization: token ${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN} " \
62
71
-d " $BUILD_PARAMS " \
63
- https://api.travis-ci.org/repo/${GITHUB_ORG} %2F${GITHUB_REPO} /requests
64
- RET=$?
65
- set -e
72
+ https://api.travis-ci.org/repo/${GITHUB_ORG} %2F${GITHUB_REPO} /requests)
66
73
67
- if [ $RET -eq 0 ]; then
68
- echo " Successfully triggered the Travis CI build."
74
+ if [[ " x_${HTTP_RESPONSE} " =~ " HTTP Status 202" ]]; then
75
+ echo " Successfully triggered the Travis CI build:"
76
+ echo " ${HTTP_RESPONSE} "
69
77
else
70
- echo " Failed to trigger the Travis CI build."
78
+ echo " Failed to trigger the Travis CI build:"
79
+ echo " ${HTTP_RESPONSE} "
71
80
exit 1
72
81
fi
0 commit comments