Setting Up Email Notifications for Jenkins Stages: Pipeline Script -
i looking send out email on failure and/or list of of stages , status. have wrapped code in try{} , catching failures. on console output says email sent appropriate email not receiving it... under configuration on jenkins have set jenkins location, e-mail notification , extended e-mail notifications set up. have confirmed e-mail notifications work , added same credentials extended e-mail notifications. here console out put:
running on dobby in d:pipelinefolder [pipeline] { [pipeline] emailext sending email to: myemail@school.edu [pipeline] stage [pipeline] { (checkout) [pipeline] checkout and
results (nunit3) saved testresult.xml [pipeline] } [pipeline] // stage [pipeline] emailext sending email to: myemail@school.edu [pipeline] } [pipeline] // node [pipeline] end of pipeline please view code below:
node('dobby') { try { notifybuild('started') stage('checkout') { checkout([$class: 'subversionscm', additionalcredentials: [], excludedcommitmessages: '', excludedregions: '', excludedrevprop: '', excludedusers: 'buildbot', filterchangelog: false, ignoredirpropchanges: false, includedregions: '', locations: [[credentialsid: 'appr0pr1at3.crdent1al5.83', depthoption: 'infinity', ignoreexternalsoption: true, local: '.', remote: "http://jenkins.svn.link.edu/svn/my/repo"]], workspaceupdater: [$class: 'updateupdater']]) } stage('build webapp') { bat 'c:/"program files (x86)/microsoft visual studio"/2017/community/msbuild/15.0/bin/msbuild.exe webapp/webapp.sln /m /p:visualstudioversion=15.0' //msbuild } stage('test: check if iis webapp on') { bat 'c:/"program files (x86)"/nunit.org/nunit-console/nunit3-console.exe seleniumnunit/seleniumnunit/bin/debug/seleniumnunit.dll' } } catch (e) { // if there exception thrown, build failed currentbuild.result = "failed" throw e } { // success or failure, send notifications notifybuild(currentbuild.result) } } def notifybuild(string buildstatus = 'started') { // build status of null means successful buildstatus = buildstatus ?: 'successful' emailext( to: 'myemail@school.edu', subject: "${buildstatus}: job '${env.job_name} [${env.build_number}]'", body: "details", recipientproviders: [[$class: 'developersrecipientprovider']] ) } can identify reasons why not receiving emails?
so... unchecked use smtp authentication under extended e-mail notifications , worked! need wrap head around now...
Comments
Post a Comment