Jenkins emailext plugin with default subject and body in pipeline script

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

Jenkins emailext plugin with default subject and body in pipeline script

David Koenig

i am using Jenkins with the email extension plugin and declarative pipelines. In https://jenkinsserver/configure i configured the "Default Subject" and "Default Content" with some variables and nice looking content which i want to use in a pipeline script.
When i add the following code to a pipeline script, everything works perfectly fine.

    post {
            always {
                emailext (
                    to: '[hidden email]',
                    replyTo: '[hidden email]',
                    subject: "foo",
                    body: "bar",
                    mimeType: 'text/html'
                );
            }
        }

So technical, everything is working perfectly. But i don't want to specify something in the pipeline script, everything should be done with the data specified in the global configuration. When i remove everything and just call `emailext ();` it failes with the comment that subject is missing. What can i do to work with default values specified globally?

Regards

Dave

--
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/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins emailext plugin with default subject and body in pipeline script

slide
Hi Dave,

Email-ext works on the idea of macros. When you define the default subject in the global config, it sets the value of a macro that you can then use in your job config. If you want to get the value you set, you have to use the macro for it.

subject: '$DEFAULT_SUBJECT'

This is the same with the other items as well. 

You could wrap this into a shared library so that it's just a simple call to do everything you want.

Regards,

Alex


On Fri, Jul 31, 2020, 00:01 David Koenig <[hidden email]> wrote:

i am using Jenkins with the email extension plugin and declarative pipelines. In https://jenkinsserver/configure i configured the "Default Subject" and "Default Content" with some variables and nice looking content which i want to use in a pipeline script.
When i add the following code to a pipeline script, everything works perfectly fine.

    post {
            always {
                emailext (
                    to: '[hidden email]',
                    replyTo: '[hidden email]',
                    subject: "foo",
                    body: "bar",
                    mimeType: 'text/html'
                );
            }
        }

So technical, everything is working perfectly. But i don't want to specify something in the pipeline script, everything should be done with the data specified in the global configuration. When i remove everything and just call `emailext ();` it failes with the comment that subject is missing. What can i do to work with default values specified globally?

Regards

Dave

--
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/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com.

--
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/CAPiUgVcy5Uz88msWBDjYxFFBs2q0%3DOqza6Q86VB9KtuQVsTGqg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins emailext plugin with default subject and body in pipeline script

David Koenig
Hi,

sorry for the late response, i was away a few days.
i am new to jenkins, so please forgive me to ask some silly questions. Did i understand this right? It doesn't work directly out of a Jenkinsfile? I tried

emailext (
                to: '[hidden email],
                replyTo: ' [hidden email]',
                subject: $DEFAULT_SUBJECT,
                body: '<b>testb</b>test<i>testi</i><p>new area</p>',
                mimeType: 'text/html'
            );

and get the error message

groovy.lang.MissingPropertyException: No such property: $DEFAULT_SUBJECT for class: WorkflowScript

Regards

Dave


slide schrieb am Freitag, 31. Juli 2020 um 14:45:23 UTC+2:
Hi Dave,

Email-ext works on the idea of macros. When you define the default subject in the global config, it sets the value of a macro that you can then use in your job config. If you want to get the value you set, you have to use the macro for it.

subject: '$DEFAULT_SUBJECT'

This is the same with the other items as well. 

You could wrap this into a shared library so that it's just a simple call to do everything you want.

Regards,

Alex


On Fri, Jul 31, 2020, 00:01 David Koenig <[hidden email]> wrote:

i am using Jenkins with the email extension plugin and declarative pipelines. In https://jenkinsserver/configure i configured the "Default Subject" and "Default Content" with some variables and nice looking content which i want to use in a pipeline script.
When i add the following code to a pipeline script, everything works perfectly fine.

    post {
            always {
                emailext (
                    to: '[hidden email]',
                    replyTo: '[hidden email]',
                    subject: "foo",
                    body: "bar",
                    mimeType: 'text/html'
                );
            }
        }

So technical, everything is working perfectly. But i don't want to specify something in the pipeline script, everything should be done with the data specified in the global configuration. When i remove everything and just call `emailext ();` it failes with the comment that subject is missing. What can i do to work with default values specified globally?

Regards

Dave

--
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/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com.

--
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/0638577a-35c9-4ee6-8f29-a6acb2160f4dn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins emailext plugin with default subject and body in pipeline script

slide
The quotes I had in my example are important, you need single quotes so that Groovy (which pipeline is built on) does not try and interpolate the variable (as you have seen, it doesn't exist in the groovy context).

emailext (
                to: '[hidden email],
                replyTo: ' [hidden email]',
                subject: '$DEFAULT_SUBJECT',
                body: '<b>testb</b>test<i>testi</i><p>new area</p>',
                mimeType: 'text/html'
            )

On Wed, Aug 5, 2020 at 5:55 AM David Koenig <[hidden email]> wrote:
Hi,

sorry for the late response, i was away a few days.
i am new to jenkins, so please forgive me to ask some silly questions. Did i understand this right? It doesn't work directly out of a Jenkinsfile? I tried

emailext (
                to: '[hidden email],
                replyTo: ' [hidden email]',
                subject: $DEFAULT_SUBJECT,
                body: '<b>testb</b>test<i>testi</i><p>new area</p>',
                mimeType: 'text/html'
            );

and get the error message

groovy.lang.MissingPropertyException: No such property: $DEFAULT_SUBJECT for class: WorkflowScript

Regards

Dave


slide schrieb am Freitag, 31. Juli 2020 um 14:45:23 UTC+2:
Hi Dave,

Email-ext works on the idea of macros. When you define the default subject in the global config, it sets the value of a macro that you can then use in your job config. If you want to get the value you set, you have to use the macro for it.

subject: '$DEFAULT_SUBJECT'

This is the same with the other items as well. 

You could wrap this into a shared library so that it's just a simple call to do everything you want.

Regards,

Alex


On Fri, Jul 31, 2020, 00:01 David Koenig <[hidden email]> wrote:

i am using Jenkins with the email extension plugin and declarative pipelines. In https://jenkinsserver/configure i configured the "Default Subject" and "Default Content" with some variables and nice looking content which i want to use in a pipeline script.
When i add the following code to a pipeline script, everything works perfectly fine.

    post {
            always {
                emailext (
                    to: '[hidden email]',
                    replyTo: '[hidden email]',
                    subject: "foo",
                    body: "bar",
                    mimeType: 'text/html'
                );
            }
        }

So technical, everything is working perfectly. But i don't want to specify something in the pipeline script, everything should be done with the data specified in the global configuration. When i remove everything and just call `emailext ();` it failes with the comment that subject is missing. What can i do to work with default values specified globally?

Regards

Dave

--
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/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com.

--
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/0638577a-35c9-4ee6-8f29-a6acb2160f4dn%40googlegroups.com.


--

--
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/CAPiUgVesLoxK7D0kwAX5c2KKzX8DX%2Bn63XRLxrpXycct_iMnmA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins emailext plugin with default subject and body in pipeline script

David Koenig
Hey man,

again what learned. Thank you so much, you saved my day.

regards

Dave

Am Mittwoch, 5. August 2020 17:12:38 UTC+2 schrieb slide:
The quotes I had in my example are important, you need single quotes so that Groovy (which pipeline is built on) does not try and interpolate the variable (as you have seen, it doesn't exist in the groovy context).

emailext (
                to: '[hidden email],
                replyTo: ' [hidden email]',
                subject: '$DEFAULT_SUBJECT',
                body: '<b>testb</b>test<i>testi</i><p>new area</p>',
                mimeType: 'text/html'
            )

On Wed, Aug 5, 2020 at 5:55 AM David Koenig <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CIEVoJWUBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">david....@...> wrote:
Hi,

sorry for the late response, i was away a few days.
i am new to jenkins, so please forgive me to ask some silly questions. Did i understand this right? It doesn't work directly out of a Jenkinsfile? I tried

emailext (
                to: '[hidden email],
                replyTo: ' [hidden email]',
                subject: $DEFAULT_SUBJECT,
                body: '<b>testb</b>test<i>testi</i><p>new area</p>',
                mimeType: 'text/html'
            );

and get the error message

groovy.lang.MissingPropertyException: No such property: $DEFAULT_SUBJECT for class: WorkflowScript

Regards

Dave


slide schrieb am Freitag, 31. Juli 2020 um 14:45:23 UTC+2:
Hi Dave,

Email-ext works on the idea of macros. When you define the default subject in the global config, it sets the value of a macro that you can then use in your job config. If you want to get the value you set, you have to use the macro for it.

subject: '$DEFAULT_SUBJECT'

This is the same with the other items as well. 

You could wrap this into a shared library so that it's just a simple call to do everything you want.

Regards,

Alex


On Fri, Jul 31, 2020, 00:01 David Koenig <[hidden email]> wrote:

i am using Jenkins with the email extension plugin and declarative pipelines. In <a href="https://jenkinsserver/configure" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkinsserver%2Fconfigure\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHBOtkLexV0P2uDVEE3Gf8bUBF3nA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkinsserver%2Fconfigure\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHBOtkLexV0P2uDVEE3Gf8bUBF3nA&#39;;return true;">https://jenkinsserver/configure i configured the "Default Subject" and "Default Content" with some variables and nice looking content which i want to use in a pipeline script.
When i add the following code to a pipeline script, everything works perfectly fine.

    post {
            always {
                emailext (
                    to: '[hidden email]',
                    replyTo: '[hidden email]',
                    subject: "foo",
                    body: "bar",
                    mimeType: 'text/html'
                );
            }
        }

So technical, everything is working perfectly. But i don't want to specify something in the pipeline script, everything should be done with the data specified in the global configuration. When i remove everything and just call `emailext ();` it failes with the comment that subject is missing. What can i do to work with default values specified globally?

Regards

Dave

--
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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/35d1b78c-39e9-46a9-b942-caae4d7f103cn%40googlegroups.com.

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CIEVoJWUBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/0638577a-35c9-4ee6-8f29-a6acb2160f4dn%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/0638577a-35c9-4ee6-8f29-a6acb2160f4dn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/0638577a-35c9-4ee6-8f29-a6acb2160f4dn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/0638577a-35c9-4ee6-8f29-a6acb2160f4dn%40googlegroups.com.


--
Website: <a href="http://earl-of-code.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fearl-of-code.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n4PgqhQTRQjanfDfEls_aRabFg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fearl-of-code.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n4PgqhQTRQjanfDfEls_aRabFg&#39;;return true;">http://earl-of-code.com

--
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/e7019050-e890-489e-b3e3-19c79baa8444o%40googlegroups.com.