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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Trigger subbuild on develop
  • Loading branch information
lwasylow committed Jul 8, 2018
commit c54c14b03bf4b463f50c8005aacb547e3bdec370
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ script:
- if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi
- bash .travis/push_docs_to_gh_pages.sh

after_success:
- if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN fi

before_deploy:
- bash .travis/build_release_archive.sh

Expand Down
71 changes: 71 additions & 0 deletions .travis/trigger_travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

# Trigger a new Travis-CI job.
# Ordinarily, a new Travis job is triggered when a commit is pushed to a
# GitHub repository. The trigger-travis.sh script provides a programmatic
# way to trigger a new Travis job.

# To use this script to trigger a dependent build in Travis, do two things:
#
# 1. Set an environment variable TRAVIS_ACCESS_TOKEN by navigating to
# https://travis-ci.org/MYGITHUBID/MYGITHUBPROJECT/settings
# The TRAVIS_ACCESS_TOKEN environment variable will be set when Travis runs
# the job, but won't be visible to anyone browsing https://travis-ci.org/.
#


TRAVIS_URL=travis-ci.org
BRANCH=develop
USER="utPLSQL"
RESULT=1
declare -a REPO_MATRIX=("utPLSQL-java-api" "utPLSQL-v2-v3-migration" "utPLSQL-cli")

TOKEN=$1

if [ -n "$TRAVIS_REPO_SLUG" ] ; then
MESSAGE=",\"message\": \"Triggered by upstream build of $TRAVIS_REPO_SLUG commit "`git rev-parse --short HEAD`"\""
else
MESSAGE=",\"message\": \"Triggered manually from shell\""
fi

## For debugging:
# echo "TOKEN=$TOKEN"
# echo "MESSAGE=$MESSAGE"

body="{
\"request\": {
\"branch\":\"$BRANCH\"
$MESSAGE
}}"

for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do

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_URL}/repo/${USER}%2F${DOWNSTREAM_BUILD}/requests \
| tee ${DOWNSTREAM_BUILD}-output.txt

if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then
#exit 1
RESULT=0
echo ""
echo "Failed to start ${DOWNSTREAM_BUILD}"
echo ""
fi
if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then
#exit 1
RESULT=0
echo ""
echo "Failed to start ${DOWNSTREAM_BUILD}"
echo ""
fi

done

if [[ RESULT -eq 0 ]]; then
exit 1
fi