mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
114 lines
4.3 KiB
Plaintext
114 lines
4.3 KiB
Plaintext
import groovy.json.JsonOutput
|
|
|
|
def notifyPagurePR(repo, msg, status, phase, credentials = 'fm-orchestrator-auth'){
|
|
def json = JsonOutput.toJson([name: 'pagure', url: env.JOB_NAME, build: [full_url: currentBuild.absoluteUrl, status: status, number: currentBuild.number, phase: phase]])
|
|
println json
|
|
|
|
withCredentials([string(credentialsId: credentials, variable: "PAGURE_PUSH_SECRET")]) {
|
|
/* We need to notify pagure that jenkins finished but then pagure will
|
|
wait for jenkins to be done, so if we wait for pagure's answer we're
|
|
basically stuck in a loop where both jenkins and pagure are waiting
|
|
for each other */
|
|
sh "timeout 1 curl -X POST -d \'$json\' https://pagure.io/api/0/ci/jenkins/$repo/${PAGURE_PUSH_SECRET}/build-finished -H \"Content-Type: application/json\" | true"
|
|
}
|
|
}
|
|
|
|
def onmyduffynode(script){
|
|
ansiColor('xterm'){
|
|
timestamps{
|
|
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${DUFFY_NODE}.ci.centos.org -t "' + script + '"'
|
|
}
|
|
}
|
|
}
|
|
|
|
node('factory2'){
|
|
|
|
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'){
|
|
onmyduffynode 'yum -y install git docker && systemctl start docker'
|
|
}
|
|
|
|
stage('Clone Test Suite') {
|
|
timeout(time: 10, unit: 'MINUTES') {
|
|
onmyduffynode "GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone --single-branch https://pagure.io/fm-orchestrator.git"
|
|
onmyduffynode "cd fm-orchestrator && git remote add proposed \"${env.REPO}\""
|
|
onmyduffynode "cd fm-orchestrator && GIT_TRACE=1 GIT_CURL_VERBOSE=1 git fetch proposed"
|
|
onmyduffynode "cd fm-orchestrator && git checkout origin/master"
|
|
onmyduffynode "cd fm-orchestrator && git config --global user.email ci@centos.org"
|
|
onmyduffynode "cd fm-orchestrator && git config --global user.name CentOS CI"
|
|
onmyduffynode "cd fm-orchestrator && git merge --no-ff \"proposed/${env.BRANCH}\" -m \'Merge PR\'"
|
|
onmyduffynode "cd fm-orchestrator && git log -2"
|
|
}
|
|
}
|
|
|
|
stage('Pull Container Images') {
|
|
parallel centos: {
|
|
stage('Pull quay.io/factory2/mbs-test-centos') {
|
|
onmyduffynode 'docker pull quay.io/factory2/mbs-test-centos'
|
|
}
|
|
},
|
|
fedora: {
|
|
stage('Pull quay.io/factory2/mbs-test-fedora') {
|
|
onmyduffynode 'docker pull quay.io/factory2/mbs-test-fedora'
|
|
}
|
|
},
|
|
postgres: {
|
|
stage('Pull docker.io/postgres:9.5.17') {
|
|
onmyduffynode 'docker pull docker.io/postgres:9.5.17'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Run Test Suites') {
|
|
timeout(30) {
|
|
parallel py2_sqlite: {
|
|
stage('Test with Python 2 & SQLite') {
|
|
onmyduffynode '~/fm-orchestrator/run-unittests.sh --no-tty'
|
|
}
|
|
},
|
|
py3_sqlite: {
|
|
stage('Test with Python 3 & SQLite') {
|
|
onmyduffynode '~/fm-orchestrator/run-unittests.sh --py3 --no-tty'
|
|
}
|
|
},
|
|
py3_postgres: {
|
|
stage('Test with Python 3 & Postgresql') {
|
|
onmyduffynode '~/fm-orchestrator/run-unittests.sh --py3 --with-pgsql --no-tty'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}catch (e){
|
|
currentBuild.result = "FAILED"
|
|
throw e
|
|
} finally {
|
|
stage('Deallocate Node'){
|
|
sh 'cico node done ${SSID}'
|
|
}
|
|
|
|
stage('Notify PR'){
|
|
res = currentBuild.currentResult
|
|
notifyPagurePR("fm-orchestrator", "Build " + res + "! ", res, "FINALIZED")
|
|
}
|
|
|
|
}
|
|
}
|