Email Extension Plugin - "groovy.lang.MissingPropertyException: No such property:" exception when trying to print the message contents

1,260 views
Skip to first unread message

Adri CS

unread,
Oct 13, 2016, 9:44:01 AM10/13/16
to Jenkins Users
Dear all,

In a project, I'm trying to access to the message contents in the Pre-send script.
I'm trying to add those contents to the log.

I've set up the message type directly to text/plain and specified the Default Contents to a string (let's say: "ABCDEF").

So in the Pre-send script, I'm executing the following piece of code:

logger.println(msg.getContentType());
logger
.println(msg.getContent());
logger
.println(${PROJECT_DEFAULT_CONTENT});

*) The first line will print text/plain as expected.

*) The second line will print javax.mail.internet.MimeMultipart@4d0c4f81

*) And the third line will throw the groovy.lang.MissingPropertyException: No such property: exception.

 The complete message is:

groovy.lang.MissingPropertyException: No such property: ABCDEF for class: Script1
    at org
.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
    at org
.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
    at org
.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
    at
Script1.run(Script1.groovy:39)
    at groovy
.lang.GroovyShell.evaluate(GroovyShell.java:585)
    at groovy
.lang.GroovyShell.evaluate(GroovyShell.java:623)
    at groovy
.lang.GroovyShell.evaluate(GroovyShell.java:594)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:528)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:481)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:365)
    at hudson
.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:350)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:258)
    at hudson
.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson
.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson
.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
    at hudson
.model.Build$BuildExecution.cleanUp(Build.java:195)
    at hudson
.model.Run.execute(Run.java:1767)
    at hudson
.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson
.model.ResourceController.execute(ResourceController.java:98)
    at hudson
.model.Executor.run(Executor.java:404)

groovy
.lang.MissingPropertyException: No such property: ABCDEFGHIJKLMNOPQRSTUVWXYZ for class: Script1
    at org
.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
    at org
.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
    at org
.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
    at
Script1.run(Script1.groovy:39)
    at groovy
.lang.GroovyShell.evaluate(GroovyShell.java:585)
    at groovy
.lang.GroovyShell.evaluate(GroovyShell.java:623)
    at groovy
.lang.GroovyShell.evaluate(GroovyShell.java:594)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:528)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:481)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:365)
    at hudson
.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:350)
    at hudson
.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:258)
    at hudson
.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson
.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson
.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
    at hudson
.model.Build$BuildExecution.cleanUp(Build.java:195)
    at hudson
.model.Run.execute(Run.java:1767)
    at hudson
.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson
.model.ResourceController.execute(ResourceController.java:98)
    at hudson
.model.Executor.run(Executor.java:404)


My questions are:

  *) Why the message's content is being reported as multipart, even though I forcefully specified text/plain?

  *) Why trying to access the message's content throws the exception?

Best regards,
Adrian

Slide

unread,
Oct 13, 2016, 9:57:35 AM10/13/16
to Jenkins Users

You are missing double quotes around the variable.

logger.println("${PROJECT_DEFAULT_CONTENT}");


--
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/3324d8bb-b1f4-4233-bcec-2d9d473d0c60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adri CS

unread,
Oct 13, 2016, 10:15:41 AM10/13/16
to Jenkins Users
Hi slide,

yes. That was it! Thanks!

Altough why is the content being reported as multipart when it's a plain text string?

Cheers!

Slide

unread,
Oct 13, 2016, 10:17:00 AM10/13/16
to Jenkins Users

The messages are always sent as multipart, even for plain text messages.


Reply all
Reply to author
Forward
0 new messages