Skip to content

Instantly share code, notes, and snippets.

@infotexture
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infotexture/8742667 to your computer and use it in GitHub Desktop.
Save infotexture/8742667 to your computer and use it in GitHub Desktop.
Sample Jenkins build script to generate output via DITA-OT & copy results to web server
#!/bin/bash
# This script is run by Jenkins to execute all tests.
# It gets passed two parameters, the first one is either "ci" or "nightly" to
# indicate what kind of tests should be run. The second one is the branch that
# is being tested. This script should either work for all branches (makes
# merging easier) or each branch contains code that is specific for this branch,
# in which case you might want to double check that everything works after
# merging.
# Call this script (`build-files/jenkins`) in the Build section of the Jenkins
# job configuration via Add build step > Execute shell > command:
# BRANCH=$(basename $GIT_BRANCH)
# ./build-files/jenkins ci $BRANCH
if [ "$1" == "ci" ]; then
echo "Continuous integration check for branch $2"
RET=0
set +e # if one command fails then exit
# Run documentation build script, which sets up the DITA-OT environment & runs Ant tasks to build output
bash build-files/build.sh
BRANCH=$(basename $GIT_BRANCH)
# Clean & re-create target output directory before moving the new generated output
rm -r /var/www/$BRANCH/manual
mkdir /var/www/$BRANCH/manual
# Copy all `output` subfolders to Web server "as-is"
cp -r output/* /var/www/$BRANCH/manual
exit $RET
elif [ "$1" == "nightly" ]; then
echo "Nightly check for branch $2"
RET=0
#make || RET=1
exit $RET
else
echo "Unknown parameter: $1" && exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment