vide_public/Jenkinsfile

185 lines
5.6 KiB
Groovy

pipeline {
agent {
kubernetes {
inheritFrom 'ubuntu-builder'
defaultContainer 'ubuntu'
retries 1
activeDeadlineSeconds 10800
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
triggers {
pollSCM('H H(0-7) * * *')
}
environment {
DOC_DEPLOYER = credentials('Doc deployment')
}
stages {
stage('Preparation') {
steps {
script {
branchName = 'guilhem/jenkins_1.0'
cred = '0c503fb7-7bad-459f-81f1-71467b382d39'
env.PYTHON_VENV = """${sh(
returnStdout:true,
script: 'BTAG=$(echo ${BUILD_TAG} | sed "s,%,,g"); echo -n "${WORKSPACE}/${BTAG}"'
)}"""
}
}
}
stage('Source') { // for display purposes
steps {
git branch: branchName, credentialsId: cred, url: 'git@bitbucket.org:cosmicvoids/vide_public.git'
sh 'python3 -m venv ${PYTHON_VENV}'
sh 'ls && echo ${PYTHON_VENV} && ls ${PYTHON_VENV}'
sh 'test -e ${PYTHON_VENV}'
// sh 'git submodule init'
// sh 'git submodule update --recursive'
}
}
// stage('Download deps') {
// steps {
// ansiColor('xterm') {
// sh '''
// export BORG_PREDOWNLOAD=/build/jenkins/borg_downloads
// if [[ -d ${BORG_PREDOWNLOAD} ]]; then
// rm -fr downloads/
// rsync -r ${BORG_PREDOWNLOAD}/ downloads/
// rm -f downloads/deps.txt
// fi
// bash build.sh --download-deps
// rsync -r downloads/ ${BORG_PREDOWNLOAD}/
// '''
// }
// }
// }
stage('Configure') {
steps {
ansiColor('xterm') {
sh '''
. ${PYTHON_VENV}/bin/activate
pip install setuptools
export VIDE_PREDOWNLOAD=/jenkins-cache/vide_downloads
if ! test -d ${VIDE_PREDOWNLOAD}; then
mkdir ${VIDE_PREDOWNLOAD}
fi
CMAKE_PREFIX_PATH=${VIRTUAL_ENV}:/opt/boost
export CMAKE_PREFIX_PATH
mkdir build
cd build
cmake -DVIDE_DOWNLOAD_CACHE=${VIDE_PREDOWNLOAD} -DINSTALL_PYTHON_LOCAL=OFF -DCMAKE_INSTALL_PREFIX=${PYTHON_VENV} ..
'''
}
}
}
stage('Build') {
steps {
ansiColor('xterm') {
dir('build') {
sh 'make -j1'
}
}
}
}
// stage('Tests') {
// steps {
// dir('build') {
// sh """
// . ${PYTHON_VENV}/bin/activate
// pip3 install wheel pytest jax[cpu] numpy deprecated
// ctest -V
// """
// }
// }
// }
// stage('Install') {
// steps {
// dir('build') {
// sh 'make install'
// }
// }
// }
// stage("Doc") {
// steps {
// dir('docs') {
// sh """
// . ${PYTHON_VENV}/bin/activate
// export PYTHONWARNINGS=always::ImportWarning
// pip3 install wheel
// pip3 install -r requirements.txt
// rm -fr source/_generate
// rm -fr _build
// make html
// tar -C _build/html -zcvf doc.tgz .
// curl -v -F filename=doc -F file=@doc.tgz http://athos.iap.fr:9595/deploy-doc2/$DOC_DEPLOYER/borg-main
// """
// }
// }
// }
}
post {
failure {
notifyBuild("FAIL")
}
success {
notifyBuild("SUCCESS")
}
always {
/* clean up our workspace */
deleteDir()
/* clean up tmp directory */
dir("${PYTHON_VENV}") {
deleteDir()
}
dir("${workspace}@tmp") {
deleteDir()
}
}
}
}
def notifyBuild(String buildStatus = 'STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
// Override default values based on build status
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#0000FF'
} else if (buildStatus == 'SUCCESS') {
color = 'GREEN'
colorCode = '#00FF00'
} else {
color = 'RED'
colorCode = '#FF0000'
}
def details = """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>
<p>Build status: <span style='color: ${colorCode};'>${buildStatus}</span></p>"""
emailext (
mimeType: 'text/html',
subject: subject,
body: details,
recipientProviders: [developers(), requestor()]
)
}