diff --git a/Jenkinsfile b/Jenkinsfile index eab3e30..3fdb8bb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,126 +1,134 @@ 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 "use_mpi = \'true\'" >> build-setup.conf echo "verbose = \'true\'" >> build-setup.conf''' } } stage('Compile') { steps { sh '''#!/usr/bin/env bash set -o pipefail rm -rf .sconf_temp .sconsign.dblite build-release scons | tee compilation.txt''' } post { failure { uploadArtifact('compilation.txt', 'Compilation') uploadArtifact('config.log', 'Configure log') } always { archiveArtifacts artifacts: 'compilation.txt', fingerprint: true archiveArtifacts artifacts: 'config.log', fingerprint: true } } } stage('Run tests') { steps { - sh 'PYTHONPATH=$PWD/build-release/python/ python3 -m pytest --durations=0 --junitxml=results.xml build-release/tests' + sh '''#!/usr/bin/env bash + set -o pipefail + PYTHONPATH=$PWD/build-release/python/ python3 -m pytest -vvv --durations=0 --junitxml=results.xml build-release/tests | tee tests.log''' + } + + post { + always { + archiveArtifacts artifacts: 'tests.log', fingerprint: true + } } } } 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@protonmail.com', 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 "./tests/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/ """ }