diff --git a/Jenkinsfile b/Jenkinsfile index e88527a2a..c8a092738 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,153 +1,147 @@ pipeline { parameters {string(defaultValue: '', description: 'api-token', name: 'API_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') } options { disableConcurrentBuilds() } environment { PHABRICATOR_HOST = 'https://c4science.ch/api/' PYTHONPATH = sh returnStdout: true, script: 'echo ${WORKSPACE}/test/ci/script/' BLA_VENDOR = 'OpenBLAS' OMPI_MCA_plm = 'isolated' OMPI_MCA_btl = 'tcp,self' } agent { dockerfile { filename 'Dockerfile' dir 'test/ci' additionalBuildArgs '--tag akantu-environment' } } stages { stage('Configure') { steps { sh """ env mkdir -p build cd build cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE \ -DAKANTU_IMPLICIT:BOOL=TRUE \ -DAKANTU_PARALLEL:BOOL=TRUE \ -DAKANTU_PYTHON_INTERFACE:BOOL=TRUE \ -DAKANTU_TESTS:BOOL=TRUE .. """ } post { failure { deleteDir() } } } stage('Compile') { steps { sh 'make -C build/src || true' } } stage ('Warnings gcc') { steps { warnings(consoleParsers: [[parserName: 'GNU Make + GNU C Compiler (gcc)']]) } } stage('Compile python') { steps { sh 'make -C build/python || true' } } stage('Compile tests') { steps { sh 'make -C build/test || true' } } stage('Tests') { steps { sh ''' rm -rf build/gtest_reports cd build/ #source ./akantu_environement.sh ctest -T test --no-compress-output || true ''' } post { always { script { def TAG = sh returnStdout: true, script: 'head -n 1 < build/Testing/TAG' def TAG_ = TAG.trim() if (fileExists("build/Testing/${TAG}/Test.xml")) { sh "cp build/Testing/${TAG}/Test.xml CTestResults.xml" } } } } } } post { always { step([$class: 'XUnitBuilder', thresholds: [ [$class: 'SkippedThreshold', failureThreshold: '0'], [$class: 'FailedThreshold', failureThreshold: '0']], tools: [ [$class: 'CTestType', pattern: 'CTestResults.xml', skipNoTestFiles: true] ]]) step([$class: 'XUnitBuilder', thresholds: [ [$class: 'SkippedThreshold', failureThreshold: '100'], [$class: 'FailedThreshold', failureThreshold: '0']], tools: [ [$class: 'GoogleTestType', pattern: 'build/gtest_reports/**', skipNoTestFiles: true] ]]) createArtifact("./CTestResults.xml") } success { passed() } failure { emailext( body: '''${SCRIPT, template="groovy-html.template"}''', mimeType: 'text/html', subject: "[Jenkins] ${currentBuild.fullDisplayName} Failed", recipientProviders: [[$class: 'CulpritsRecipientProvider']], to: 'akantu-admins@akantu.ch', replyTo: 'akantu-admins@akantu.ch', attachLog: true, compressLog: false) failed() } } } def failed() { sh "./test/ci/scripts/hbm -a ${API_TOKEN} -b ${BUILD_TARGET_PHID} failed" } def passed() { sh "./test/ci/scripts/hbm passed" } def createArtifact(artefact) { - sh """ - ./test/ci/scripts/hbm \ - send-uri -k "Jenkins URI" -l "View Jenkins result" + sh "./test/ci/scripts/hbm send-uri -k 'Jenkins URI' -u ${BUILD_URL} -l 'View Jenkins result'" - if [ -e ${artefact} ]; then - ./test/ci/scripts/hbm \ - send-ctest-results -f ${artefact} - fi - """ + sh "./test/ci/scripts/hbm send-ctest-results -f ${artefact}" } diff --git a/test/ci/scripts/hbm b/test/ci/scripts/hbm index c3cf0279e..4eed91740 100755 --- a/test/ci/scripts/hbm +++ b/test/ci/scripts/hbm @@ -1,47 +1,48 @@ #!/usr/bin/env python3 import click import harbomaster @click.group() @click.option('-a', '--api-token', default=None, envvar='API_TOKEN') @click.option('-h', '--host', default=None, envvar='PHABRICATOR_HOST') @click.option('-b', '--build-target-phid', envvar='BUILD_TARGET_PHID') @click.pass_context def hbm(ctx, api_token, host, build_target_phid): ctx.obj['API_TOKEN'] = api_token ctx.obj['HOST'] = host ctx.obj['BUILD_TARGET_PHID'] = build_target_phid @hbm.command() @click.option('-f', '--filename') @click.pass_context def send_ctest_results(ctx, filename): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) with harbomaster.CTestResults(filename) as tests: _hbm.send_unit_tests(tests) @hbm.command() @click.option('-k', '--key') +@click.option('-u', '--uri') @click.option('-l', '--label') @click.pass_context -def send_uri(ctx, key, label): +def send_uri(ctx, key, uri, label): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) - _hbm.send_uri(key, label) + _hbm.send_uri(key, uri, label) @hbm.command() @click.pass_context def passed(ctx): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) _hbm.passed() @hbm.command() @click.pass_context def failed(ctx): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) _hbm.failed() if __name__ == '__main__': hbm(obj={})