def onmyduffynode(script){
ansiColor('xterm'){
timestamps{
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${DUFFY_NODE}.ci.centos.org -t REPO=${REPO} BRANCH=${BRANCH} "' + script + '"'
}
}
}
def syncfromduffynode(rsyncpath){
sh 'rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root " -Ha --include=' + rsyncpath + " ${DUFFY_NODE}.ci.centos.org:~/ ./"
}
node('pagure') {
properties([
parameters([
string(defaultValue: "", description: "", name: "REPO"),
string(defaultValue: "", description: "", name: "BRANCH"),
])
])
stage('Allocate Node'){
env.CICO_API_KEY = readFile("${env.HOME}/duffy.key").trim()
duffy_rtn=sh(
script: 'cico --debug node get -f value -c hostname -c comment',
returnStdout: true
).trim().tokenize(' ')
env.DUFFY_NODE=duffy_rtn[0]
env.SSID=duffy_rtn[1]
}
try {
stage('Pre Setup Node'){
// Install EPEL
onmyduffynode 'yum -y install epel-release git'
}
stage('Clone Test Suite') {
if (env.BRANCH_NAME){
onmyduffynode "git clone -b \"${env.BRANCH_NAME}\" --single-branch --depth 1 https://pagure.io/pagure.git"
} else {
onmyduffynode "git clone --single-branch --depth 1 https://pagure.io/pagure.git"
}
}
stage('Run Test Suite') {
timeout(time: 6, unit: 'HOURS') {
onmyduffynode 'cd pagure && sh ./run_ci_tests.sh'
}
}
} catch (e) {
currentBuild.result = "FAILED"
throw e
} finally {
stage('Sync Artifacts'){
syncfromduffynode('pagure/*.out')
}
stage('Deallocate Node'){
sh 'cico node done ${SSID}'
}
stage('Archive Artifacts'){
archiveArtifacts artifacts: 'pagure/*.out'
}
}
}