Skip to content

Instantly share code, notes, and snippets.

@brianv0
Created June 28, 2018 16:50
Show Gist options
  • Save brianv0/341637477df5d3716fdc205621d5d06a to your computer and use it in GitHub Desktop.
Save brianv0/341637477df5d3716fdc205621d5d06a to your computer and use it in GitHub Desktop.
Parallel Jenkins
def project = "GlastRelease"
def known_host = "github.com,192.30.255.112 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="
properties([
parameters([
stringParam(
name: 'repoman_ref',
description: 'Branch, Ref or Commit to build'
)
])
])
if (!params.repoman_ref){
echo "Nothing to Build"
currentBuild.result = "SUCCESS"
return
}
if (params.description){
currentBuild.description = description
}
def blessed = 'glast'
def variants = ['centos6-x86_64-64bit-gcc44', 'rhel6-x86_64-64bit-gcc44']
def images = [
"centos6-x86_64-64bit-gcc44":'fermilat/base:centos6-py27-gcc44',
"rhel6-x86_64-64bit-gcc44":'fermilat/base:centos6-py27-gcc44',
]
def builders = [:]
for (x in variants) {
def variant = x // Need to bind the label variable before the closure - can't do 'for (label in labels)'
builders[variant] = {
node('docker') {
deleteDir()
def os_arch_compiler = "centos6-x86_64-64bit-gcc44"
docker.image(images[variant]).inside {
stage('Initialize Workspace') {
if(!fileExists("/home/centos/.local/lib64")){
sh "mkdir -p /home/centos/.local/lib"
sh "ln -s /home/centos/.local/lib /home/centos/.local/lib64"
}
sh "mkdir ~/.ssh && echo '${known_host}' > ~/.ssh/known_hosts"
sh 'pip install scons fermi-repoman'
sshagent (credentials: ['glast.slac.stanford.edu']) {
sh "repoman checkout ${project} ${repoman_ref}"
}
}
stage('Compile and Test') {
sh """scons -C GlastRelease --site-dir=../SConsShared/site_scons --with-GLAST-EXT='' --compile-opt --compile-debug --externalsList | grep -v scons | grep -v '=\\|\\:\\|(\\|Creating' | grep [A-Za-z] | sed 's/ /-/' > externals.txt"""
sh 'curl -O "https://gist.githubusercontent.com/brianv0/d6a71f9b38ec20093972ab49ab6e602b/raw/5393d651c575cb00f3faafca9b35e40f8d219bd0/load_externals.sh"'
sh 'bash load_externals.sh'
def artifact_name = "${JOB_BASE_NAME}-${BUILD_NUMBER}-${os_arch_compiler}"
sh "env"
sh """scons -j 4 \
-C ${project} --site-dir=../SConsShared/site_scons \
--compile-opt --compile-debug \
--with-GLAST-EXT=`pwd`/externals"""
sh """
mkdir ${artifact_name}
cp -r bin/${os_arch_compiler}-Debug-Optimized ${artifact_name}/bin
cp -r exe/${os_arch_compiler}-Debug-Optimized ${artifact_name}/exe
cp -r lib/${os_arch_compiler}-Debug-Optimized ${artifact_name}/lib
cp -r jobOptions ${artifact_name}/jobOptions
cp -r data ${artifact_name}/data
cp -r include ${artifact_name}/include
cp -r python ${artifact_name}/python
cp -r xml ${artifact_name}/xml
tar czf ${artifact_name}.tar.gz ${artifact_name}
"""
archive "${artifact_name}.tar.gz"
}
}
}
}
}
parallel builders
node (blessed) {
stage('validate') {
echo "[Validation]"
}
stage('deploy') {
echo "[Deployment]"
//sh 'cp /nfs/slac/g/glast/ground/containers/singularity/containers.master.img.gz .'
//archive 'containers.master.img.gz'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment