Environment Variables in pre-send Script ( Editable E-mail Notification)

3,932 views
Skip to first unread message

William Toner

unread,
May 3, 2013, 10:33:37 AM5/3/13
to jenkins...@googlegroups.com
 
Hi,
 
I would like to setup a conditional in the pre-send Script of the Editable E-mail notification, ideally based upon an ENV set by a job Parameter: eg. PREVIEW
I.e., if the PREVIEW boolean is check-boxed, then I do not want e-mail to be sent ( so I presume I'd set cancel to true ).
 
When I execute a snippet to dump the ENVs from the pre-send Script area, it appears as though no Parameter ENVs are accessible.
 
def env = System.getenv();
env.each{
 logger.println it
}
 
// I do not see my ENV from this output.
 
// Here's the snippet I would like to have work for me.

String preview = env['PREVIEW'];
if ( preview.equals("true") ) cancel=true;
 
Thoughts on how to make this work?
 
Thanks!
 
-Bill
 

Slide

unread,
May 3, 2013, 10:53:21 AM5/3/13
to jenkins...@googlegroups.com
You probably want to use build.getEnvironment(listener) to get the instance of the EnvVars. See [1] and [2]

slide



 

--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Website: http://earl-of-code.com

William Toner

unread,
May 3, 2013, 5:16:31 PM5/3/13
to jenkins...@googlegroups.com
 
Hey, Thanks, that worked.  Here's what I ended up with in case it's useful to someone else some day...
 

def env = build.getEnvironment()

Reply all
Reply to author
Forward
0 new messages