Page MenuHomec4science

Jenkinsfile
No OneTemporary

File Metadata

Created
Sat, Nov 23, 23:09

Jenkinsfile

pipeline {
parameters {string(defaultValue: '', description: 'api-token', name: 'API_TOKEN')
string(defaultValue: '', description: 'Token for readthedocs', name: 'RTD_TOKEN')
string(defaultValue: '', description: 'buildable phid', name: 'BUILD_TARGET_PHID')
string(defaultValue: '', description: 'Commit id', name: 'COMMIT_ID')
string(defaultValue: '', description: 'Diff id', name: 'DIFF_ID')
string(defaultValue: 'PHID-PROJ-gbo56hpf2y5bi7t5jusk', description: 'ID of the project', name: 'PROJECT_ID')
}
environment {
PHABRICATOR_HOST = 'https://c4science.ch/api/'
PYTHONPATH = sh returnStdout: true, script: 'echo ${WORKSPACE}/tests/ci/script/'
}
agent {
dockerfile { additionalBuildArgs '--tag tamaas-environment'}
}
stages {
stage('SCM Checkout') {
steps {
checkout scm: [
$class: 'GitSCM',
branches: scm.branches,
extensions: [[
$class: 'SubmoduleOption',
recursiveSubmodules: true,
]],
userRemoteConfigs: scm.userRemoteConfigs
]
}
}
stage('Configure') {
steps {
sh '''#!/usr/bin/env bash
echo "py_exec = \'python3\'" > build-setup.conf
echo "build_python = \'true\'" >> build-setup.conf
echo "build_tests = \'true\'" >> build-setup.conf
echo "use_googletest = \'true\'" >> build-setup.conf
echo "legacy_bem = \'true\'" >> build-setup.conf'''
}
}
stage('Compile') {
steps {
sh '''#!/usr/bin/env bash
set -o pipefail
rm -rf .sconf_temp .sconsign.dblite
scons | tee compilation.txt'''
}
post {
failure {
uploadArtifact('compilation.txt', 'Compilation')
}
}
}
stage('Run tests') {
steps {
sh 'PYTHONPATH=build-release/python/ python3 -m pytest --ignore=build-release/tests/test_hertz_kato.py --junitxml=results.xml build-release'
}
}
}
post {
always {
createArtifact("results.xml")
junit 'results.xml'
step([$class: 'XUnitBuilder',
thresholds: [
[$class: 'SkippedThreshold', failureThreshold: '0'],
[$class: 'FailedThreshold', failureThreshold: '0']],
tools: [[$class: 'GoogleTestType', pattern: 'build-release/tests/gtest_results.xml']]])
}
success {
trigger_rtd()
passed_hbm()
}
failure {
failed_hbm()
emailext(
body: '''${SCRIPT, template="groovy-html.template"}''',
mimeType: 'text/html',
subject: "[Jenkins] ${currentBuild.fullDisplayName} Failed",
recipientProviders: [[$class: 'CulpritsRecipientProvider']],
to: 'lucas.frerot@epfl.ch',
attachLog: true,
compressLog: true)
}
}
}
def createArtifact(filename) {
sh "./tests/ci/scripts/hbm send-uri -k 'Jenkins URI' -u ${BUILD_URL} -l 'View Jenkins result'"
sh "./tests/ci/scripts/hbm send-junit-results -f ${filename}"
}
def uploadArtifact(artifact, name) {
sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v ${PROJECT_ID}"
}
def failed_hbm() {
sh "./tests/ci/scripts/hbm failed"
}
def passed_hbm() {
sh "./tests/ci/scripts/hbm passed"
}
def trigger_rtd() {
sh """
set -x
curl -X POST -d "token=${RTD_TOKEN}" https://readthedocs.org/api/v2/webhook/tamaas/106141/
"""
}

Event Timeline