sending email for unstable builds

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

sending email for unstable builds

Faad Sayaou
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c7db49d-68ef-4c41-8cd2-39ff6855ad83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Sagar Utekar-2
You can check the status of build by using BUILD_STATUS, if it is unstable then send a mail

On Fri, 1 Mar 2019, 02:11 Faad Sayaou, <[hidden email]> wrote:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c7db49d-68ef-4c41-8cd2-39ff6855ad83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANYh6tf5h6_LAafRrKLROquy3mO95puNkbMY0%3DATh5uRnkXeyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Simon Bayer
Dear Faad, dear Sagar,
U could check the global variable  'currentBuild.currentResult' in e.g. post build actions. Maybe it suits your needs. Doks: https://opensource.triology.de/jenkins/pipeline-syntax/globals#currentBuild

Best regards


-------- Ursprüngliche Nachricht --------
Von: Sagar Utekar <[hidden email]>
Datum: 01.03.19 03:06 (GMT+01:00)
Betreff: Re: sending email for unstable builds

You can check the status of build by using BUILD_STATUS, if it is unstable then send a mail

On Fri, 1 Mar 2019, 02:11 Faad Sayaou, <[hidden email]> wrote:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c7db49d-68ef-4c41-8cd2-39ff6855ad83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANYh6tf5h6_LAafRrKLROquy3mO95puNkbMY0%3DATh5uRnkXeyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/DM6PR15MB3452322898E87D82EF2A5E41AC760%40DM6PR15MB3452.namprd15.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Simon Bayer
Check This if u need post build actions for different build status: https://jenkins.io/doc/pipeline/tour/post/


-------- Ursprüngliche Nachricht --------
Von: Simon Bayer <[hidden email]>
Datum: 01.03.19 06:32 (GMT+01:00)
Betreff: Re: sending email for unstable builds

Dear Faad, dear Sagar,
U could check the global variable  'currentBuild.currentResult' in e.g. post build actions. Maybe it suits your needs. Doks: https://opensource.triology.de/jenkins/pipeline-syntax/globals#currentBuild

Best regards


-------- Ursprüngliche Nachricht --------
Von: Sagar Utekar <[hidden email]>
Datum: 01.03.19 03:06 (GMT+01:00)
Betreff: Re: sending email for unstable builds

You can check the status of build by using BUILD_STATUS, if it is unstable then send a mail

On Fri, 1 Mar 2019, 02:11 Faad Sayaou, <[hidden email]> wrote:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c7db49d-68ef-4c41-8cd2-39ff6855ad83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANYh6tf5h6_LAafRrKLROquy3mO95puNkbMY0%3DATh5uRnkXeyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/DM6PR15MB3452B3FF105E05324B50A9C4AC760%40DM6PR15MB3452.namprd15.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Faad Sayaou
thanks @Simon and @Sagar for your responses.  'currentBuild.currentResult' is definitely what i needed and works as intended. 

On Fri, 1 Mar 2019 at 06:37, Simon Bayer <[hidden email]> wrote:
Check This if u need post build actions for different build status: https://jenkins.io/doc/pipeline/tour/post/


-------- Ursprüngliche Nachricht --------
Von: Simon Bayer <[hidden email]>
Datum: 01.03.19 06:32 (GMT+01:00)
Betreff: Re: sending email for unstable builds

Dear Faad, dear Sagar,
U could check the global variable  'currentBuild.currentResult' in e.g. post build actions. Maybe it suits your needs. Doks: https://opensource.triology.de/jenkins/pipeline-syntax/globals#currentBuild

Best regards


-------- Ursprüngliche Nachricht --------
Von: Sagar Utekar <[hidden email]>
Datum: 01.03.19 03:06 (GMT+01:00)
Betreff: Re: sending email for unstable builds

You can check the status of build by using BUILD_STATUS, if it is unstable then send a mail

On Fri, 1 Mar 2019, 02:11 Faad Sayaou, <[hidden email]> wrote:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c7db49d-68ef-4c41-8cd2-39ff6855ad83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANYh6tf5h6_LAafRrKLROquy3mO95puNkbMY0%3DATh5uRnkXeyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/DM6PR15MB3452B3FF105E05324B50A9C4AC760%40DM6PR15MB3452.namprd15.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.


--

Best Regards / Mit freundlichen Grüßen,

Faad Sayaou,

Embedded Systems for Mechatronics Masters student | FH Dortmund | Germany

Fachhochschule Dortmund

University of Applied Sciences and Arts

Email[hidden email][hidden email]


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAL2KjjQ-6Q66229-Zh-5BRYtMvRANN-dmOZCwteJ7Re9n%3D1Tcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Simon Bayer
Vers Nice, appreciate your feedback. Glad that We could help you :)


-------- Ursprüngliche Nachricht --------
Von: Faad Sayaou <[hidden email]>
Datum: 01.03.19 08:34 (GMT+01:00)
Betreff: Re: sending email for unstable builds

thanks @Simon and @Sagar for your responses.  'currentBuild.currentResult' is definitely what i needed and works as intended. 

On Fri, 1 Mar 2019 at 06:37, Simon Bayer <[hidden email]> wrote:
Check This if u need post build actions for different build status: https://jenkins.io/doc/pipeline/tour/post/


-------- Ursprüngliche Nachricht --------
Von: Simon Bayer <[hidden email]>
Datum: 01.03.19 06:32 (GMT+01:00)
Betreff: Re: sending email for unstable builds

Dear Faad, dear Sagar,
U could check the global variable  'currentBuild.currentResult' in e.g. post build actions. Maybe it suits your needs. Doks: https://opensource.triology.de/jenkins/pipeline-syntax/globals#currentBuild

Best regards


-------- Ursprüngliche Nachricht --------
Von: Sagar Utekar <[hidden email]>
Datum: 01.03.19 03:06 (GMT+01:00)
Betreff: Re: sending email for unstable builds

You can check the status of build by using BUILD_STATUS, if it is unstable then send a mail

On Fri, 1 Mar 2019, 02:11 Faad Sayaou, <[hidden email]> wrote:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c7db49d-68ef-4c41-8cd2-39ff6855ad83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANYh6tf5h6_LAafRrKLROquy3mO95puNkbMY0%3DATh5uRnkXeyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/DM6PR15MB3452B3FF105E05324B50A9C4AC760%40DM6PR15MB3452.namprd15.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.


--

Best Regards / Mit freundlichen Grüßen,

Faad Sayaou,

Embedded Systems for Mechatronics Masters student | FH Dortmund | Germany

Fachhochschule Dortmund

University of Applied Sciences and Arts

Email[hidden email][hidden email]


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAL2KjjQ-6Q66229-Zh-5BRYtMvRANN-dmOZCwteJ7Re9n%3D1Tcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/BN8PR15MB3441D00AC2AAA06CB8709368AC760%40BN8PR15MB3441.namprd15.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Mark Lübbehüsen
In reply to this post by Faad Sayaou
Hi,

its better you send emails in the post action

post {
      always {
           
}
        success {
        }
        unstable {

        
}
        failure {
           
}
aborted {
}
    }

https://jenkins.io/doc/pipeline/tour/post/


Am Donnerstag, 28. Februar 2019 21:41:50 UTC+1 schrieb Faad Sayaou:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. <a href="https://jenkins-map.1worldsync.com/job/Heinemann_Build_pipeline/$%7BBUILD_NUMBER%7D/console" rel="nofollow" style="color:rgb(17,85,204)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;">https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e3a993c8-7263-40f7-a421-6effb374611e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Faad Sayaou
thanks for your contribution. Is there any other way of failing of failing the pipeline when unit test stage is unstable? I have something like the following in my code to ignore the failed test but I will like to stop the pipeline and publish unit test result.

I am currently experiencing a strange effect when using the MStest plugin. My test report is only generated when the test is successful but when it fails, no test report is generated. 

node {

        stage('Checkout') {
            cleanWs()
            checkout scm

            return
            skipRemainingStages = true
        }


        stage('Restore') {

            sh "dotnet restore  $proj"

        }

        stage('Build') {
            sh "dotnet publish $proj --output $outputFolder --configuration Release -p:Version=$buildVersion -p:FileVersion=$buildVersion"

       }
        stage ('Unit test') {

               sh  "dotnet restore $UnitTest"
               sh returnStdout: true, script: "dotnet test $UnitTest --logger \'trx;LogFileName=unit_tests.xml\' || true"

               step ([$class: 'MSTestPublisher', testResultsFile:"**/*.xml", failOnError: true, keepLongStdio: true])

        } 
         stage ('publish') {
        }
}

I do not want to publish when the build is unstable. Like I mentioned earlier. I want to stop the build and publish test result. I tried using answers suggested above but could not help in my use-case.any idea?

On Monday, 11 March 2019 14:14:40 UTC+1, Mark Lübbehüsen wrote:
Hi,

its better you send emails in the post action

post {
      always {
           
}
        success {
        }
        unstable {

        
}
        failure {
           
}
aborted {
}
    }

<a href="https://jenkins.io/doc/pipeline/tour/post/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Ftour%2Fpost%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGozSeE0oa2-hN4h-qzAN8rhOFDQw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Ftour%2Fpost%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGozSeE0oa2-hN4h-qzAN8rhOFDQw&#39;;return true;">https://jenkins.io/doc/pipeline/tour/post/


Am Donnerstag, 28. Februar 2019 21:41:50 UTC+1 schrieb Faad Sayaou:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. <a href="https://jenkins-map.1worldsync.com/job/Heinemann_Build_pipeline/$%7BBUILD_NUMBER%7D/console" rel="nofollow" style="color:rgb(17,85,204)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;">https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2387b46c-4e0d-4747-81ec-b8c6dae3316c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Mark Lübbehüsen
HI,

you can fail your pipeline if you put the following code in the unit test stage

script {
                currentBuild.result = currentBuild.result ?: 'FAILED'
          } 

Am Dienstag, 12. März 2019 23:31:43 UTC+1 schrieb Faad Sayaou:
thanks for your contribution. Is there any other way of failing of failing the pipeline when unit test stage is unstable? I have something like the following in my code to ignore the failed test but I will like to stop the pipeline and publish unit test result.

I am currently experiencing a strange effect when using the MStest plugin. My test report is only generated when the test is successful but when it fails, no test report is generated. 

node {

        stage('Checkout') {
            cleanWs()
            checkout scm

            return
            skipRemainingStages = true
        }


        stage('Restore') {

            sh "dotnet restore  $proj"

        }

        stage('Build') {
            sh "dotnet publish $proj --output $outputFolder --configuration Release -p:Version=$buildVersion -p:FileVersion=$buildVersion"

       }
        stage ('Unit test') {

               sh  "dotnet restore $UnitTest"
               sh returnStdout: true, script: "dotnet test $UnitTest --logger \'trx;LogFileName=unit_tests.xml\' || true"

               step ([$class: 'MSTestPublisher', testResultsFile:"**/*.xml", failOnError: true, keepLongStdio: true])

        } 
         stage ('publish') {
        }
}

I do not want to publish when the build is unstable. Like I mentioned earlier. I want to stop the build and publish test result. I tried using answers suggested above but could not help in my use-case.any idea?

On Monday, 11 March 2019 14:14:40 UTC+1, Mark Lübbehüsen wrote:
Hi,

its better you send emails in the post action

post {
      always {
           
}
        success {
        }
        unstable {

        
}
        failure {
           
}
aborted {
}
    }

<a href="https://jenkins.io/doc/pipeline/tour/post/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Ftour%2Fpost%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGozSeE0oa2-hN4h-qzAN8rhOFDQw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Ftour%2Fpost%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGozSeE0oa2-hN4h-qzAN8rhOFDQw&#39;;return true;">https://jenkins.io/doc/pipeline/tour/post/


Am Donnerstag, 28. Februar 2019 21:41:50 UTC+1 schrieb Faad Sayaou:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. <a href="https://jenkins-map.1worldsync.com/job/Heinemann_Build_pipeline/$%7BBUILD_NUMBER%7D/console" rel="nofollow" style="color:rgb(17,85,204)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;">https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ef162989-92db-4143-b7ba-b6134dc0e431%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Mark Lübbehüsen
In reply to this post by Faad Sayaou
script {
                currentBuild.result = currentBuild.result ?: 'FAILED'
       }




Am Dienstag, 12. März 2019 23:31:43 UTC+1 schrieb Faad Sayaou:
thanks for your contribution. Is there any other way of failing of failing the pipeline when unit test stage is unstable? I have something like the following in my code to ignore the failed test but I will like to stop the pipeline and publish unit test result.

I am currently experiencing a strange effect when using the MStest plugin. My test report is only generated when the test is successful but when it fails, no test report is generated. 

node {

        stage('Checkout') {
            cleanWs()
            checkout scm

            return
            skipRemainingStages = true
        }


        stage('Restore') {

            sh "dotnet restore  $proj"

        }

        stage('Build') {
            sh "dotnet publish $proj --output $outputFolder --configuration Release -p:Version=$buildVersion -p:FileVersion=$buildVersion"

       }
        stage ('Unit test') {

               sh  "dotnet restore $UnitTest"
               sh returnStdout: true, script: "dotnet test $UnitTest --logger \'trx;LogFileName=unit_tests.xml\' || true"

               step ([$class: 'MSTestPublisher', testResultsFile:"**/*.xml", failOnError: true, keepLongStdio: true])

        } 
         stage ('publish') {
        }
}

I do not want to publish when the build is unstable. Like I mentioned earlier. I want to stop the build and publish test result. I tried using answers suggested above but could not help in my use-case.any idea?

On Monday, 11 March 2019 14:14:40 UTC+1, Mark Lübbehüsen wrote:
Hi,

its better you send emails in the post action

post {
      always {
           
}
        success {
        }
        unstable {

        
}
        failure {
           
}
aborted {
}
    }

<a href="https://jenkins.io/doc/pipeline/tour/post/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Ftour%2Fpost%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGozSeE0oa2-hN4h-qzAN8rhOFDQw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Ftour%2Fpost%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGozSeE0oa2-hN4h-qzAN8rhOFDQw&#39;;return true;">https://jenkins.io/doc/pipeline/tour/post/


Am Donnerstag, 28. Februar 2019 21:41:50 UTC+1 schrieb Faad Sayaou:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable. Below is the structure of my pipeline 
node {
       
   
try
   
{
 
    stage
('Checkout') {
            cleanWs
()
            checkout scm

       
}


        stage
('Restore') {

            sh
"dotnet restore  $proj"

       
}

        stage
('Build') {
            sh
"dotnet restore  $proj"

       
}
        stage
('Unit test') {

           sh
"dotnet test  $test"
       
}
   
}
} catch (err) {
     emailext body
:
            ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do something about that. <a href="https://jenkins-map.1worldsync.com/job/Heinemann_Build_pipeline/$%7BBUILD_NUMBER%7D/console" rel="nofollow" style="color:rgb(17,85,204)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-map.1worldsync.com%2Fjob%2FHeinemann_Build_pipeline%2F%24%257BBUILD_NUMBER%257D%2Fconsole\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFzQrCFYErI53XT1c26uTRGViEQdQ&#39;;return true;">https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console', subject: 'FAILURE', to: 'someEmail..'
   }

I will like to send not only when the pipeline fails but when the build is unstable. thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/89ce27c6-c3fc-4479-b3f2-8fe707c9ce70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: sending email for unstable builds

Aaron Digulla
In reply to this post by Faad Sayaou
Hi,

I'm using this code:

    node(...) {
       
try {
           
...add stages here...
       
} catch(Exception e) {
            currentBuild
.result = 'FAILURE' // Let the post step know that the build failed with an error.
           
throw e
       
} finally {
            builder
.post(currentBuild)
       
}
     
} // node

The code for post() looks like so:

    def post(def currentBuild) {
       
String currentResult = currentBuild.result ?: 'SUCCESS'
        echo
"post ${currentResult}"
       
       
try {
            postAlways
(currentBuild)
       
} catch(Exception e) {
           
def converted = toString(e)
            echo
"postAlways failed (ignored):\n${converted}"
       
}
       
       
if (currentResult == 'SUCCESS') {
            success
(currentBuild)
       
} else {
            failed
(currentBuild, currentResult)
       
}
   
}

Hope this helps,

Aaron Digulla





On Thursday, February 28, 2019 at 9:41:50 PM UTC+1, Faad Sayaou wrote:
Hi everyone
I am using the extended email plugin for notification when the build fails by using try catch. I will also like to send email when the build is unstable.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/eda1618f-94e8-4efa-9875-3d48e715a34f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.