How to specify recipients in email-ext step in declarative script?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

Danny Rehelis
Hey David,

This should be pretty straightforward, try this:
    post {
        success {
            emailext (
                to: [hidden email]; [hidden email],
                subject: "SUCCESS",
                body: "SUCCESS!"
            )
        }
        failure {
emailext (
                to: [hidden email]; [hidden email],
                subject: "FAILURE",
                body: "FAILURE!"
            )
        }
    }

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw=="> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide
Something like this might work:

script { 
    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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/CAPiUgVetEq5qDryWrRDS85Xg2uTtcFtbeo1sn97F15DD%3DPM7ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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/CAPiUgVetEq5qDryWrRDS85Xg2uTtcFtbeo1sn97F15DD%3DPM7ZA%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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide
to: "daldrich," + recipients  

Also, you may be missing a '}' to close the script block.

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Thanks Slide

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.


On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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/CAPiUgVfn_ApYwkOuM_qPVoZzucgTd71GF1HRcU5A5_P68Gui3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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/CAPiUgVfn_ApYwkOuM_qPVoZzucgTd71GF1HRcU5A5_P68Gui3A%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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide
You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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/CAPiUgVd4%3Dem9nYxTdM0KivftXZr66ix89Wv-1VB-q8-TrSJ2Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi Slide

 

Thanks for helping me with this.  I am using a declarative pipeline. In the ‘post’ clause, I set ‘success’, ‘failure’, ‘unstable’ and ‘changed’ to all be:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

 

‘Failure’ works fine – daldrich and the culprits are emailed.

 

However, when the failure is fixed, i.e. we have condition ‘changed’, only daldrich is emailed.  In a traditional job the culprits should also be notified of the change to Fixed.

 

Perhaps this is an email-ext plugin bug?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 17:45
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

 

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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/CAPiUgVd4%3Dem9nYxTdM0KivftXZr66ix89Wv-1VB-q8-TrSJ2Nw%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/4b79cb83d3b74f879f8ed762fce88f16%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide
Do you have the same recipient providers specified for the pipeline as you do in your normal (free style) job?

On Thu, May 18, 2017 at 2:33 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks for helping me with this.  I am using a declarative pipeline. In the ‘post’ clause, I set ‘success’, ‘failure’, ‘unstable’ and ‘changed’ to all be:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

 

‘Failure’ works fine – daldrich and the culprits are emailed.

 

However, when the failure is fixed, i.e. we have condition ‘changed’, only daldrich is emailed.  In a traditional job the culprits should also be notified of the change to Fixed.

 

Perhaps this is an email-ext plugin bug?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 17:45


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

 

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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].


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/4b79cb83d3b74f879f8ed762fce88f16%40EUX13SRV1.EU.NEC.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/CAPiUgVcab9VL_7JONVO2osdsvXSmUc9Xva5%2B41ZPeaz5Pg_wkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Well I haven’t found definitions of the providers so I can’t be sure, but the free-style job specifies:

 

Fixed: Recipient List, Culprits

 

and the Project Recipient List contains daldrich

 

So, yes, I think they are equivalent.

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 18 May 2017 14:52
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Do you have the same recipient providers specified for the pipeline as you do in your normal (free style) job?

 

On Thu, May 18, 2017 at 2:33 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks for helping me with this.  I am using a declarative pipeline. In the ‘post’ clause, I set ‘success’, ‘failure’, ‘unstable’ and ‘changed’ to all be:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

 

‘Failure’ works fine – daldrich and the culprits are emailed.

 

However, when the failure is fixed, i.e. we have condition ‘changed’, only daldrich is emailed.  In a traditional job the culprits should also be notified of the change to Fixed.

 

Perhaps this is an email-ext plugin bug?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 17:45


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

 

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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].


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/4b79cb83d3b74f879f8ed762fce88f16%40EUX13SRV1.EU.NEC.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/CAPiUgVcab9VL_7JONVO2osdsvXSmUc9Xva5%2B41ZPeaz5Pg_wkQ%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/3c535b8324664d338cab565b1c22ffc4%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide

Then it's possible that it's the way culprits are determined for each job type. Free style inherits from AbstractProject, so the build has a getCulprits() that email-ext can call. It has to determine culprits on its own for pipeline jobs and it may not have all the info that a free style project does.


On Thu, May 18, 2017, 07:12 David Aldrich <[hidden email]> wrote:

Well I haven’t found definitions of the providers so I can’t be sure, but the free-style job specifies:

 

Fixed: Recipient List, Culprits

 

and the Project Recipient List contains daldrich

 

So, yes, I think they are equivalent.

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 18 May 2017 14:52


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Do you have the same recipient providers specified for the pipeline as you do in your normal (free style) job?

 

On Thu, May 18, 2017 at 2:33 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks for helping me with this.  I am using a declarative pipeline. In the ‘post’ clause, I set ‘success’, ‘failure’, ‘unstable’ and ‘changed’ to all be:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

 

‘Failure’ works fine – daldrich and the culprits are emailed.

 

However, when the failure is fixed, i.e. we have condition ‘changed’, only daldrich is emailed.  In a traditional job the culprits should also be notified of the change to Fixed.

 

Perhaps this is an email-ext plugin bug?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 17:45


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

 

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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].


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/4b79cb83d3b74f879f8ed762fce88f16%40EUX13SRV1.EU.NEC.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].


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/3c535b8324664d338cab565b1c22ffc4%40EUX13SRV1.EU.NEC.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/CAPiUgVfXnC%3DQnMZcLjRz5YTSk3qmRn8qP1niaKyuNR0e%3D8zXeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to specify recipients in email-ext step in declarative script?

David Aldrich-2

Hi Slide

 

Do you know whether it’s possible to get the culprits without using email-ext, i.e. using the ‘mail’ command?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 18 May 2017 19:48
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Then it's possible that it's the way culprits are determined for each job type. Free style inherits from AbstractProject, so the build has a getCulprits() that email-ext can call. It has to determine culprits on its own for pipeline jobs and it may not have all the info that a free style project does.

 

On Thu, May 18, 2017, 07:12 David Aldrich <[hidden email]> wrote:

Well I haven’t found definitions of the providers so I can’t be sure, but the free-style job specifies:

 

Fixed: Recipient List, Culprits

 

and the Project Recipient List contains daldrich

 

So, yes, I think they are equivalent.

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 18 May 2017 14:52


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Do you have the same recipient providers specified for the pipeline as you do in your normal (free style) job?

 

On Thu, May 18, 2017 at 2:33 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks for helping me with this.  I am using a declarative pipeline. In the ‘post’ clause, I set ‘success’, ‘failure’, ‘unstable’ and ‘changed’ to all be:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

 

‘Failure’ works fine – daldrich and the culprits are emailed.

 

However, when the failure is fixed, i.e. we have condition ‘changed’, only daldrich is emailed.  In a traditional job the culprits should also be notified of the change to Fixed.

 

Perhaps this is an email-ext plugin bug?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 17:45


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

 

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click <a href="https://www.mailcontrol.com/sr/uFEKaVH2kQrGX2PQPOmvUmQbZlJUA6MY5kXy3PWbkPYgGJ5pIgYGc&#43;W6EUrkl!zFSQHHbCeqo0cKghm6!2a&#43;jw==" target="_blank"> here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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].


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/4b79cb83d3b74f879f8ed762fce88f16%40EUX13SRV1.EU.NEC.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].


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/3c535b8324664d338cab565b1c22ffc4%40EUX13SRV1.EU.NEC.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/CAPiUgVfXnC%3DQnMZcLjRz5YTSk3qmRn8qP1niaKyuNR0e%3D8zXeQ%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/c2341e79d3074e1586de3d52eb9822a8%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify recipients in email-ext step in declarative script?

slide
I don't know. It uses the Mailer plugin, so maybe you can look at the docs.

On Fri, May 19, 2017, 04:28 David Aldrich <[hidden email]> wrote:

Hi Slide

 

Do you know whether it’s possible to get the culprits without using email-ext, i.e. using the ‘mail’ command?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 18 May 2017 19:48


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Then it's possible that it's the way culprits are determined for each job type. Free style inherits from AbstractProject, so the build has a getCulprits() that email-ext can call. It has to determine culprits on its own for pipeline jobs and it may not have all the info that a free style project does.

 

On Thu, May 18, 2017, 07:12 David Aldrich <[hidden email]> wrote:

Well I haven’t found definitions of the providers so I can’t be sure, but the free-style job specifies:

 

Fixed: Recipient List, Culprits

 

and the Project Recipient List contains daldrich

 

So, yes, I think they are equivalent.

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 18 May 2017 14:52


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Do you have the same recipient providers specified for the pipeline as you do in your normal (free style) job?

 

On Thu, May 18, 2017 at 2:33 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks for helping me with this.  I am using a declarative pipeline. In the ‘post’ clause, I set ‘success’, ‘failure’, ‘unstable’ and ‘changed’ to all be:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

 

‘Failure’ works fine – daldrich and the culprits are emailed.

 

However, when the failure is fixed, i.e. we have condition ‘changed’, only daldrich is emailed.  In a traditional job the culprits should also be notified of the change to Fixed.

 

Perhaps this is an email-ext plugin bug?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 17:45


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

You are using "to: ", you don't need both to and recipientProviders, especially since you are already using the def recipients = emailext... to get the same thing. If the job succeeds, I don't think the culprits will be emailed, but I could be wrong. Are you using a pipeline or other type of job? Culprits are people who may have broken the build, so if the build is succeeding, then it may not email the culprits. You may want DevelopersRecipientProvider if you want anyone who added a change to be emailed.

 

On Wed, May 17, 2017 at 7:27 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

I am running the job manually. There are commits by another user since the job last ran, so I assume there should be culprits.  The job actually succeeds, but I’m assuming that the culprits should still receive the email.

 

If I remove:

 

recipientProviders: [[$class: 'CulpritsRecipientProvider']],

 

then the culprits definitely won’t get the email?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 17 May 2017 15:16


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Try removing the recipientProvider parameter to emailext, I'm not sure if that will mess things up. I'm not familiar with declarative pipeline enough to say how to get the correct build status. How are you running the job? If you are running it manually and there have been no changes, then there are no culprits. The culprits are pulled from the changes from the scm you specify.

 

On Wed, May 17, 2017, 04:07 David Aldrich <[hidden email]> wrote:

I tried replacing my code with that produced by the snippet generator:

 

            script{ emailext (body: '${DEFAULT_CONTENT}',

                              recipientProviders: [[$class: 'CulpritsRecipientProvider']],

                              subject: '${DEFAULT_SUBJECT}',

                              to: 'daldrich')

            }

 

But the result is an email to daldrich but not to the culprits.

 

Could this be a bug in the emailext plugin?

 

BR

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Aldrich
Sent: 17 May 2017 08:53


To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Hi Slide

 

I think the script is still not quite right.  I now have:

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                    emailext (to: "daldrich," + recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                           

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

            }

        }

    }

 

I see two problems:

 

1) The output shows:

 

Failed to create e-mail address for [hidden email] [hidden email] [hidden email]

Sending email to: [hidden email] [hidden email] [hidden email]

 

These are the correct committers’ email addresses but I have disguised them for this question.  I receive an email but I don’t know why I see the ‘Failed’ message in the log. Any ideas please?

 

2) The subject uses : '${DEFAULT_SUBJECT}', which ends with  ‘$BUILD_STATUS!’  In the received email the build status was ‘Building!’.  This is in ‘post’ so I expect the status to be ‘Success!’.  Any idea why this is wrong?

 

Best regards

 

David

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of David Aldrich
Sent: 16 May 2017 17:02
To: [hidden email]
Subject: RE: How to specify recipients in email-ext step in declarative script?

 

Thanks Slide

 

David

 

From: [hidden email] [[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 16:38
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

to: "daldrich," + recipients  

 

Also, you may be missing a '}' to close the script block.

 

On Tue, May 16, 2017 at 7:12 AM David Aldrich <[hidden email]> wrote:

Hi Slide

 

Thanks. I tried the code below based on your suggestion but the syntax of my change isn’t quite right. Can you help please?

 

    post {

        success {

            script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])

                   emailext (to: "daldrich"; recipients,

                              subject: '${DEFAULT_SUBJECT}',                                                         

                              body: '${DEFAULT_CONTENT}',  

                              recipientProviders: [[$class: 'DevelopersRecipientProvider']])

        }

    }

 

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 13: expecting ')', found ',' @ line 13, column 57.

   xt (to: "daldrich"; recipients, 

                                 ^

 

1 error

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Slide
Sent: 16 May 2017 14:39


To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Something like this might work:

 

script { 

    def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'] ])
    emailext(..., to: recipients)
}

 

On Tue, May 16, 2017 at 6:18 AM David Aldrich <[hidden email]> wrote:

Hi Danny,

 

That worked (with email addresses in quotes) – thanks.

 

Do you know how I would specify ‘to:’ as a certain email address + committers?

 

Best regards

 

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Danny Rehelis
Sent: 16 May 2017 14:08
To: [hidden email]
Subject: Re: How to specify recipients in email-ext step in declarative script?

 

Hey David,

 

This should be pretty straightforward, try this:

    post {

        success {

            emailext (

                to: [hidden email]; [hidden email],

                subject: "SUCCESS",

                body: "SUCCESS!"

            )

        }

        failure {

                                  emailext (

                to: [hidden email]; [hidden email],

                subject: "FAILURE",

                body: "FAILURE!"

            )

        }

    }

 

On Tue, May 16, 2017 at 11:25 AM David Aldrich <[hidden email]> wrote:

Hi

 

I am experimenting with declarative scripts and have this simple script:

 

pipeline {

    agent { label "mypc" }

    stages {

        stage('build') {

            steps {

                sh 'python --version'

            }

        }

    }

    post {

        success {

            script: emailext (subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",

                              body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>

                              <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",

                              recipientProviders: [$class: 'DevelopersRecipientProvider']])

        }

    }

}

 

I can’t specify the list of default recipients in the global settings for the email-ext plugin, as the required recipients change from project to project.  I need to specify the list in the script.  I’ve received a suggestion to:

 

use this pipeline step https://jenkins.io/doc/pipeline/steps/email-ext/#emailextrecipients-extended-email-recipients to get the recipients and then use the "to" parameter to the emailext step and add your own addresses to the return of that step”

 

I don’t know how to do this. Please could someone show me how to modify my script to do it?

 

Best regards

 

David

 

--
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/21c2aac48caa41998f52a2e233d4ed76%40EUX13SRV1.EU.NEC.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/CAObRFCX0ZaN4MPqiNy9tB8z0nr_g1zFrZ1Ssa24Bhb997G7p4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

--
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/1ba2614920ab4f01a957692fe395146e%40EUX13SRV1.EU.NEC.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].


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/0469c2cb3fe64a4ab024f74c10d4b214%40EUX13SRV1.EU.NEC.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/CAPiUgVe-KveLCY%2BcJDM3C-eb8ZwqtUaAhjBd_T4wZ2Sakiwo9g%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/1b7a1ef389fa4e48bbf39dce8f8f8550%40EUX13SRV1.EU.NEC.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/28f1e4b702d3473daea012b34b77b861%40EUX13SRV1.EU.NEC.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/4b69f78cd1054bd084bfd6371bebf993%40EUX13SRV1.EU.NEC.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].


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/2ba974eb543740449ab216628ee15bdf%40EUX13SRV1.EU.NEC.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].


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/4b79cb83d3b74f879f8ed762fce88f16%40EUX13SRV1.EU.NEC.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].


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/3c535b8324664d338cab565b1c22ffc4%40EUX13SRV1.EU.NEC.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].


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/c2341e79d3074e1586de3d52eb9822a8%40EUX13SRV1.EU.NEC.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/CAPiUgVew5hjqf4m2XP0FUUOLDbFWkueLfa0mcubiL%2Bkg1%2B8RTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.