Hi,

I can't seems to figure out how can I use variables I set during the build 
in pre-send section of Email-ext.
My pipeline script looks like -

node {
    FROM = 'AAA <a...@me.com>'
    emailext(
        to: "m...@email.com",
        presendScript: '''msg.setHeader("From", FROM);''',
        subject: "test",
        mimeType: 'text/html',
        body: "content"
    )
}

Resulting with -

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/Test_email
[Pipeline] {
[Pipeline] emailext
groovy.lang.MissingPropertyException: No such property: FROM for class: 
groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)
at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:284)
at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:288)
at 
org.kohsuke.groovy.sandbox.impl.Checker$checkedGetProperty$0.callStatic(Unknown 
Source)
at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:230)
at Script1.run(Script1.groovy:1)
at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:141)
at 
hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:627)
at 
hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)
at 
hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)
at 
hudson.plugins.emailext.EmailExtStep$EmailExtStepExecution.run(EmailExtStep.java:224)
at 
hudson.plugins.emailext.EmailExtStep$EmailExtStepExecution.run(EmailExtStep.java:163)
at 
org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:260)
at 
org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Sending email to: m...@email.com
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

How can I access the variable *FROM *with-in the pre-send script?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f65f386a-1c42-4965-a0c8-dd000b661787%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to