简体   繁体   中英

Jenkins “Execute Shell Script” vars needed in post-build action specifically in send email body?

So I set up some vars in Execute Shell Script build action which I would like to use in my post-build action like send email's body. Is this possible without using any plugins? If not possible without plugins what are the plugins that I should use? Thanks very much,

Not possible without plugins because:

  • Execute Shell Script and Post-build actions are run in separate environment sessions, so anything that had been set in the former is not available in the latter.

What you need is the EnvInject plugin .

  • In your Execute Shell Script step, instead of setting an environment variable, write the key-value pair to file, for example myvar=somevalue .
  • Add another build step, called Inject environment variables for your job . Give it the location of the file with the key-value pair.
  • Now that variable is available as an environment variable for the rest of the job run (including other build steps and post-build steps).

You can set any environment variable using the " Generate environment variables from script" by using: echo "MY_VAR=$SOME_VAR"

Then this variable is available through the entire jenkins job process. at any shell/ batch command and even at the mail or any other plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM