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
Fixed issue with references to TRAVIS_JOB_NUMBER in scripts.
Testing execution of `.travis/trigger-travis.sh`
  • Loading branch information
jgebal committed Jul 8, 2018
commit b3f445692f569db99021a9c50f6487ed4295be6a
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ jobs:
- pip install mkdocs
before_script: skip
script:
- if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi
# - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi
- bash .travis/trigger-travis.sh $TRAVIS_ACCESS_TOKEN #testing triggering
- if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi
- bash .travis/build_docs.sh
- bash .travis/push_docs_to_gh_pages.sh
Expand All @@ -134,5 +135,3 @@ jobs:
on:
repo: ${UTPLSQL_REPO}
tags: true
# when building from a release tag, use only first job "#xxx.1" to publish artifacts
condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$"
150 changes: 74 additions & 76 deletions .travis/push_docs_to_gh_pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,87 +17,85 @@ PAGES_TARGET_BRANCH="gh-pages"
LATEST_DOCS_BRANCH="develop"
# TRAVIS_* variables are set by travis directly and only need to be if testing externally

# Since we are running job matrix, only thie first job slave will need to do the work
if [[ "${TRAVIS_JOB_NUMBER}" =~ \.1$ ]]; then
# We don't want a pull request automatically updating the repository
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && { [ "${CURRENT_BRANCH}" == "${LATEST_DOCS_BRANCH}" ] || [ -n "${TRAVIS_TAG}" ]; }; then
# We don't want a pull request automatically updating the repository
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && { [ "${CURRENT_BRANCH}" == "${LATEST_DOCS_BRANCH}" ] || [ -n "${TRAVIS_TAG}" ]; }; then

# ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
# Anyone one of them not set can be used to turn off this functionality.
# ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
# Anyone one of them not set can be used to turn off this functionality.

# If a version of the project is not defined
[[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 0; }
# Fail if the markdown documentation is not present.
[[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; }
# If a version of the project is not defined
[[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 0; }
# Fail if the markdown documentation is not present.
[[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; }

# Save some useful information
SHA=`git rev-parse --verify HEAD`
# Save some useful information
SHA=`git rev-parse --verify HEAD`

# clone the repository and switch to PAGES_TARGET_BRANCH branch
mkdir pages
cd pages
git clone https://${github_api_token}@github.com/${UTPLSQL_REPO} .
# clone the repository and switch to PAGES_TARGET_BRANCH branch
mkdir pages
cd pages
git clone https://${github_api_token}@github.com/${UTPLSQL_REPO} .

PAGES_BRANCH_EXISTS=$(git ls-remote --heads origin ${PAGES_TARGET_BRANCH})
PAGES_BRANCH_EXISTS=$(git ls-remote --heads origin ${PAGES_TARGET_BRANCH})

if [ -n "$PAGES_BRANCH_EXISTS" ] ; then
echo "Pages Branch Found"
git checkout ${PAGES_TARGET_BRANCH}
else
echo "Creating Pages Branch"
git checkout --orphan ${PAGES_TARGET_BRANCH}
git rm -rf .
fi
#clear out develop documentation directory and copy docs contents to it.
echo "updating 'develop' directory"
mkdir -p develop
rm -rf develop/**./* || exit 0
cp -a ../docs/. ./develop
# If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
if [ -n "$TRAVIS_TAG" ]; then
echo "Creating ${UTPLSQL_VERSION}"
mkdir -p ${UTPLSQL_VERSION}
rm -rf ${UTPLSQL_VERSION}/**./* || exit 0
cp -a ../docs/. ${UTPLSQL_VERSION}
echo "Populating 'latest' directory"
mkdir -p latest
rm -rf latest/**./* || exit 0
cp -a ../docs/. latest
fi
# Stage changes for commit
git add .
#Check if there are doc changes, if none exit the script
if [[ -z `git diff HEAD --exit-code` ]] && [ -n "${PAGES_BRANCH_EXISTS}" ] ; then
echo "No changes to docs detected."
exit 0
fi
#Changes where detected, so we need to update the version log.
now=$(date +"%d %b %Y - %r")
if [ ! -f index.md ]; then
echo "---" >>index.md
echo "layout: default" >>index.md
echo "---" >>index.md
echo "<!-- Auto generated from .travis/push_docs_to_gh_pages.sh -->" >>index.md
echo "# Documentation versions" >>index.md
echo "" >>index.md
echo "" >>index.md #- 7th line - placeholder for latest release doc
echo "" >>index.md #- 8th line - placeholder for develop branch doc
echo "" >>index.md
echo "## Released Version Doc History" >>index.md
echo "" >>index.md
fi
#If build running on a TAG - it's a new release - need to add it to documentation
if [ -n "${TRAVIS_TAG}" ]; then
sed -i '7s@.*@'" - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now"'@' index.md
#add entry to the top of version history (line end of file - ## Released Version Doc History
sed -i '12i'" - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
fi
#replace 4th line in log
sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md
#Add and Commit the changes back to pages repo.
git add .
git commit -m "Deploy to gh-pages branch: base commit ${SHA}"
# Now that we're all set up, we can push.
git push --quiet origin HEAD:${PAGES_TARGET_BRANCH}
if [ -n "$PAGES_BRANCH_EXISTS" ] ; then
echo "Pages Branch Found"
git checkout ${PAGES_TARGET_BRANCH}
else
echo "Creating Pages Branch"
git checkout --orphan ${PAGES_TARGET_BRANCH}
git rm -rf .
fi
#clear out develop documentation directory and copy docs contents to it.
echo "updating 'develop' directory"
mkdir -p develop
rm -rf develop/**./* || exit 0
cp -a ../docs/. ./develop
# If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
if [ -n "$TRAVIS_TAG" ]; then
echo "Creating ${UTPLSQL_VERSION}"
mkdir -p ${UTPLSQL_VERSION}
rm -rf ${UTPLSQL_VERSION}/**./* || exit 0
cp -a ../docs/. ${UTPLSQL_VERSION}
echo "Populating 'latest' directory"
mkdir -p latest
rm -rf latest/**./* || exit 0
cp -a ../docs/. latest
fi
# Stage changes for commit
git add .
#Check if there are doc changes, if none exit the script
if [[ -z `git diff HEAD --exit-code` ]] && [ -n "${PAGES_BRANCH_EXISTS}" ] ; then
echo "No changes to docs detected."
exit 0
fi
#Changes where detected, so we need to update the version log.
now=$(date +"%d %b %Y - %r")
if [ ! -f index.md ]; then
echo "---" >>index.md
echo "layout: default" >>index.md
echo "---" >>index.md
echo "<!-- Auto generated from .travis/push_docs_to_gh_pages.sh -->" >>index.md
echo "# Documentation versions" >>index.md
echo "" >>index.md
echo "" >>index.md #- 7th line - placeholder for latest release doc
echo "" >>index.md #- 8th line - placeholder for develop branch doc
echo "" >>index.md
echo "## Released Version Doc History" >>index.md
echo "" >>index.md
fi
#If build running on a TAG - it's a new release - need to add it to documentation
if [ -n "${TRAVIS_TAG}" ]; then
sed -i '7s@.*@'" - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now"'@' index.md
#add entry to the top of version history (line end of file - ## Released Version Doc History
sed -i '12i'" - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
fi
#replace 4th line in log
sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md
#Add and Commit the changes back to pages repo.
git add .
git commit -m "Deploy to gh-pages branch: base commit ${SHA}"
# Now that we're all set up, we can push.
git push --quiet origin HEAD:${PAGES_TARGET_BRANCH}
fi

20 changes: 7 additions & 13 deletions .travis/push_release_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
# - branch name is = develop or branch name is like release/vX.X.X...
if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [[ "${CURRENT_BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|develop)$ ]]; then
echo Current branch is "${CURRENT_BRANCH}"
echo Current job number is "${TRAVIS_JOB_NUMBER}"
#The publishing is done only once (for first job on a build matrix)
if [[ "${TRAVIS_JOB_NUMBER}" =~ \.1$ ]]; then
echo "Committing version & buildNo into branch (${CURRENT_BRANCH})"
git add sonar-project.properties
git add VERSION
git add source/*
git commit -m 'Updated project version after build [skip ci]'
echo "Pushing to origin"
git push --quiet origin HEAD:${CURRENT_BRANCH}
else
echo "Publishing of version skipped for job No.: ${TRAVIS_JOB_NUMBER}"
fi
echo "Committing version & buildNo into branch (${CURRENT_BRANCH})"
git add sonar-project.properties
git add VERSION
git add source/*
git commit -m 'Updated project version after build [skip ci]'
echo "Pushing to origin"
git push --quiet origin HEAD:${CURRENT_BRANCH}
else
echo "Publishing of version skipped for branch ${CURRENT_BRANCH}, pull request ${TRAVIS_PULL_REQUEST}"
fi
5 changes: 2 additions & 3 deletions .travis/trigger_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ else
MESSAGE=",\"message\": \"Triggered manually from shell\""
fi

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

body="{
\"request\": {
Expand Down