I would like to cancel email sending based on the value of a boolean parameter of a parameterized job. The parameter is named "skip.email".
I tried to write a pre-send script with following content but it doesn't work :
def env = System.getenv()
logger.println("Should I skip email ? " + env['skip.email'])
cancel = env['skip.email']
Here is what I see in the logs :
Should I skip email ? null
I tried to print out all environment variables, but none of the parameters of my parameterized Jenkins job are in the list.
Please help me out, thank you in advance !
The parameters of a Parameterized job are not environment variables!! They can't be accessed that way. If you want to access them, use the Environment Inject Plugin to add them to the environment as a build step and then follow these steps. It should fix your problem.