Skip to content

Instantly share code, notes, and snippets.

@dmclean62
Created July 30, 2020 17:42
Show Gist options
  • Save dmclean62/e1d1302ebea803fa4f3e3db50d3cef6e to your computer and use it in GitHub Desktop.
Save dmclean62/e1d1302ebea803fa4f3e3db50d3cef6e to your computer and use it in GitHub Desktop.
/**
* @file Jenkinsfile.ci
* @brief Jenkins pipeline build script for change integration builds
*/
// load helper library installed in jenkins
// NOTE: This library is loaded from the git repo ssh://gerrit/dsbjenkins.git
// To peg to a particular tag of that repository, use @<tag name>
@Library('[email protected]')
def dj = new edu.stsci.dsb.jenkins.utilities()
// node expression for where to build
def releaseBuildNodeExpr = 'RHEL7 && HST'
// artifacts to archive
def buildArtifacts = [
'artifacts/*'
].join(',')
// people that get notified when builds fail
def mailRecipients = [
<redacted>
].join(' ')
// start the build
node(releaseBuildNodeExpr) {
// common environment variables needed - has to be here for custom tools
def jobEnv = [
"JAVA_HOME=/usr/local/Java/jdk11.0.1",
"ANT_HOME=${tool 'Ant 1.9.7'}",
"CLOC_HOME=${tool 'cloc 1.74'}"
]
try {
stage('Clone') { timestamps {
dj.notifySlack('STARTED')
dj.checkoutGerritChange('prompt')
} }
stage('Build') { timestamps {
withEnv(jobEnv) {
sh(
'''/bin/bash -xe
# make a place for artifacts
mkdir artifacts || true
# build prompt war
cd alertobs && ${ANT_HOME}/bin/ant -verbose && cd ..
mv alertobs/prompt.war artifacts/
# syntax check the perl scripts with system perl
/usr/bin/perl -c alertaq/alertaq.pl
/usr/bin/perl -c alertpi/alertpi.pl
# create a delivery for alertaq
mkdir -p dist/alertaq || true
cp -a alertaq/* dist/alertaq/
cp -a docs/alertaq_users_guide.html dist/alertaq/
cd dist
tar -cjf ../artifacts/alertaq.tar.bz2 alertaq
''')
}
} }
stage('Report') { timestamps {
// run and publish sloccount output
withEnv(jobEnv) {
sh('''env PATH=${CLOC_HOME}:$PATH cloc --by-file --xml --out=cloc.xml alertobs alertpi alertaq db''')
}
sloccountPublish encoding: '', pattern: 'cloc.xml'
} }
stage('Archive') { timestamps {
archiveArtifacts([ \
artifacts: buildArtifacts, \
excludes: null \
])
} }
currentBuild.result = 'SUCCESS'
} catch (Exception e) {
println e
currentBuild.result = 'FAILURE'
} finally {
stage('Notify') { timestamps {
dj.notifyUsers(mailRecipients)
dj.notifySlack(currentBuild.result)
// don't forget chuck norris!! (he'll kill you!!)
step([$class: 'CordellWalkerRecorder'])
} }
}
} // end of node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment