Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c54c14b

Browse files
committed
Trigger subbuild on develop
1 parent 7afc6ef commit c54c14b

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ script:
104104
- if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi
105105
- bash .travis/push_docs_to_gh_pages.sh
106106

107+
after_success:
108+
- if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN fi
109+
107110
before_deploy:
108111
- bash .travis/build_release_archive.sh
109112

.travis/trigger_travis.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
# Trigger a new Travis-CI job.
4+
# Ordinarily, a new Travis job is triggered when a commit is pushed to a
5+
# GitHub repository. The trigger-travis.sh script provides a programmatic
6+
# way to trigger a new Travis job.
7+
8+
# To use this script to trigger a dependent build in Travis, do two things:
9+
#
10+
# 1. Set an environment variable TRAVIS_ACCESS_TOKEN by navigating to
11+
# https://travis-ci.org/MYGITHUBID/MYGITHUBPROJECT/settings
12+
# The TRAVIS_ACCESS_TOKEN environment variable will be set when Travis runs
13+
# the job, but won't be visible to anyone browsing https://travis-ci.org/.
14+
#
15+
16+
17+
TRAVIS_URL=travis-ci.org
18+
BRANCH=develop
19+
USER="utPLSQL"
20+
RESULT=1
21+
declare -a REPO_MATRIX=("utPLSQL-java-api" "utPLSQL-v2-v3-migration" "utPLSQL-cli")
22+
23+
TOKEN=$1
24+
25+
if [ -n "$TRAVIS_REPO_SLUG" ] ; then
26+
MESSAGE=",\"message\": \"Triggered by upstream build of $TRAVIS_REPO_SLUG commit "`git rev-parse --short HEAD`"\""
27+
else
28+
MESSAGE=",\"message\": \"Triggered manually from shell\""
29+
fi
30+
31+
## For debugging:
32+
# echo "TOKEN=$TOKEN"
33+
# echo "MESSAGE=$MESSAGE"
34+
35+
body="{
36+
\"request\": {
37+
\"branch\":\"$BRANCH\"
38+
$MESSAGE
39+
}}"
40+
41+
for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do
42+
43+
curl -s -X POST \
44+
-H "Content-Type: application/json" \
45+
-H "Accept: application/json" \
46+
-H "Travis-API-Version: 3" \
47+
-H "Authorization: token ${TOKEN}" \
48+
-d "$body" \
49+
https://api.${TRAVIS_URL}/repo/${USER}%2F${DOWNSTREAM_BUILD}/requests \
50+
| tee ${DOWNSTREAM_BUILD}-output.txt
51+
52+
if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then
53+
#exit 1
54+
RESULT=0
55+
echo ""
56+
echo "Failed to start ${DOWNSTREAM_BUILD}"
57+
echo ""
58+
fi
59+
if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then
60+
#exit 1
61+
RESULT=0
62+
echo ""
63+
echo "Failed to start ${DOWNSTREAM_BUILD}"
64+
echo ""
65+
fi
66+
67+
done
68+
69+
if [[ RESULT -eq 0 ]]; then
70+
exit 1
71+
fi

0 commit comments

Comments
 (0)