------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------
------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------
---within DEPLOYSCRIPT---
ENV SET EXITMSG="Opps, something bad happened"ENV SET EXITVAL=1---you BASH logic---
# unset our key environment variables before we start# to begin with a clean slateunset EXITMSG EXITVALuv DEPLOYSCRIPT# deal with the results[ -n "${EXITMSG}" ] && echo "${EXITMSG}"exit ${EXITVAL}Failing that, you can easily write your result code and any appropriate message to a unix file before exiting uv, and use bash to read those and react.
------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------
---within DEPLOYSCRIPT---
ENV SET EXITMSG="Opps, something bad happened"ENV SET EXITVAL=1---you BASH logic---
# unset our key environment variables before we start# to begin with a clean slateunset EXITMSG EXITVALuv DEPLOYSCRIPT# deal with the results[ -n "${EXITMSG}" ] && echo "${EXITMSG}"exit ${EXITVAL}Failing that, you can easily write your result code and any appropriate message to a unix file before exiting uv, and use bash to read those and react.
------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC AU
------------------------------
We do a similar thing but within AWS using their CodeDeploy stuff to deploy from BitBucket. I wrote several scripts to shift the source code out of BitBucket repository, tar it up and ship it to the destination UV host for installation. I the compile script I have the following lines to check the output of the compile.
A central linux-based deployment server acts as the gateway between AWS CodeDeploy, BitBucket and our destination UniVerse server and runs the scripts.
## Excerpt from Peter's "installSourcePackage.sh"
echo "`date '+%b %d %T'` Unpacking source code to $BUILDHOST:$BUILDDIR" >> $LOGFILE
scp /tmp/$SRCPKG $BUILDUSER@$BUILDHOST:$BUILDDIR
#echo "ssh -l $BUILDUSER $BUILDHOST \\"cd $BUILDDIR ; gunzip -c $SRCPKG | tar xf -\\"" >> $LOGFILE
ssh -l $BUILDUSER $BUILDHOST "cd $BUILDDIR ; gunzip -c $SRCPKG | tar xf -"
echo "`date '+%b %d %T'` Initiating the new build environment for $BUILDDIR" >> $LOGFILE
ssh -l $BUILDUSER $BUILDHOST "cd $BUILDDIR ; /opt/uv/bin/uv < buildAccountSetup.ini"
ssh -l $BUILDUSER $BUILDHOST "rm -f $BUILDDIR/build.out"
for SRCDIR in $SRCDIRLIST ; do
echo "`date '+%b %d %T'` Compiling source code for $SRCDIR" >> $LOGFILE
ssh -l $BUILDUSER $BUILDHOST "cd $BUILDDIR ; /opt/uv/bin/uv \\"BASIC $SRCDIR *\\" >> build.out 2>&1" >> $LOGFILE
done
STATUS=`ssh -l $BUILDUSER $BUILDHOST "cd $BUILDDIR ; grep \\"No Object Code Produced\\" build.out | wc -l"`
if [ $STATUS -gt 0 ]; then
# Failed to compile one or more programs
echo "`date '+%b %d %T'` Failed with $STATUS programs failing to compile. See $BUILDHOST:$BUILDDIR/build.out" >> $LOGFILE
exit 1
fi
STATUS=`ssh -l $BUILDUSER $BUILDHOST "cd $BUILDDIR ; grep \\"Compilation Complete\\" build.out | wc -l"`
if [ ! $STATUS -gt 0 ]; then
# No compilation complete? Something bad has happened here
echo "`date '+%b %d %T'` Failed with $STATUS programs compiled. See $BUILDHOST:$BUILDDIR/build.out" >> $LOGFILE
exit 1
fi
The exit 1 is trapped by CodeDeploy and signals that the BitBucket deployment pipeline has failed. We can then go and review $LOGFILE to determine which program failed compilation or other error(s). Of course, you can interrogate $? from any command and assign it to some variable and act upon that if it is not zero and you need to report the actual error rather then just "exit 1" like I did above.
Hope this is of some help.
Regards,
Peter
PS There is no "shell script" language to select for adding code samples so I chose javascript. If the syntax highlighting is off then that is why.
PPS Can we get "shell script" language added to code samples please?
------------------------------
Peter Cheney
Developer and Systems Superstar
Firstmac
Brisbane Qld Australia
------------------------------
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.