Syntax for "mail to" in declarative script?

14 views
Skip to first unread message

David Aldrich

unread,
May 15, 2017, 8:19:41 AM5/15/17
to jenkins...@googlegroups.com
Hi

Where can I find a definition and syntax for "mail to" for a declarative script?

Specifically I want to know:

1) Is it possible to specify a recipient by user name rather than full email address?
2) How to specify 'committers'?
3) How can I set the message body to be similar to that sent by a traditional Jenkins job (i.e. result, change summary, and tail end of console output) ?

Best regards

David

David Aldrich

unread,
May 15, 2017, 9:36:42 AM5/15/17
to jenkins...@googlegroups.com
Asking my question another way:

Where can I find a list of objects / variables that a script can access, e.g. ${currentBuild.fullDisplayName} ?

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 jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-
> users/25b2d3d8ea2945e3b984a245b76e64dc%40EUX13SRV1.EU.NEC.COM.
> For more options, visit https://groups.google.com/d/optout.
>
>
> Click
> https://www.mailcontrol.com/sr/AwURFJXg0gXGX2PQPOmvUnR5FqKQsdnpf
> CFmutQSpk3Ud74aUasi!U6pqUrLpVx4LmpRHg8Q9WoJwVIOzJj0SQ== to
> report this email as spam.

David Aldrich

unread,
May 15, 2017, 12:40:28 PM5/15/17
to jenkins...@googlegroups.com
I'm a little further on - I've added a call to emailext. Below is declarative script. But I get error:

An attempt to send an e-mail to empty list of recipients, ignored.

How can I set the recipients list? Do I need another script step?

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']])
}
}
}
Reply all
Reply to author
Forward
0 new messages