diff --git a/Jenkins/Jenkinsfile.training b/Jenkins/Jenkinsfile.training index 8fdd0b0..a67465e 100644 --- a/Jenkins/Jenkinsfile.training +++ b/Jenkins/Jenkinsfile.training @@ -1,6 +1,7 @@ node { checkout scm - docker.image('s444452/ium:1.3').inside { + try { + docker.image('s444452/ium:1.3').inside { stage('Preparation') { properties([ pipelineTriggers([upstream(threshold: hudson.model.Result.SUCCESS, upstreamProjects: "s444452-create-dataset")]), @@ -26,22 +27,31 @@ node { stage('Archive artifacts') { archiveArtifacts "neural_network_evaluation.txt, model/**" } + } + } catch (e) { + currentBuild.result = "FAILED" + throw e + } finally { + notifyBuild(currentBuild.result) } - post { - success { - emailext body: 'SUCCESS', subject: 's444452-training', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' - } - unstable { - emailext body: 'UNSTABLE', subject: 's444452-training', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' - } - failure { - emailext body: 'FAILURE', subject: 's444452-training', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' - } - not_built { - emailext body: 'NOT_BUILT', subject: 's444452-training', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' - } - aborted { - emailext body: 'ABORTED', subject: 's444452-training', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' - } +} +def notifyBuild(String buildStatus = 'STARTED') { + buildStatus = buildStatus ?: 'SUCCESS' + + def subject = "Job: ${env.JOB_NAME}" + def details = "Build nr: ${env.BUILD_NUMBER}, status: ${buildStatus} \n url: ${env.BUILD_URL}" + + // Override default values based on build status + if (buildStatus == 'SUCCESS') { + color = 'GREEN' + colorCode = '#00FF00' + } else { + color = 'RED' + colorCode = '#FF0000' } + emailext ( + subject: subject, + body: details, + // recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) } \ No newline at end of file