简体   繁体   中英

How can I pass variables to post-build actions in Jenkins?

I am trying to send an email in a post-build action, with the content set to some results I computed in a build action. I cannot seem to be able to pass variables from the shell code to any post-build actions.

I have tried with EnvInject, but haven't managed to make it work.

What am I missing?

As it always happens, I managed to find the solution right after I posted the question.

I managed to solve it by having something like this in the shell script bit:

EMAIL_CONTENT=$(cat <<EOF
Some content here.
Some content there.
EOF
)

EMAIL_RECIPIENTS="someone@example.com"    

touch email_properties
echo "EMAIL_CONTENT=${EMAIL_CONTENT}" >> email_properties
echo "EMAIL_RECIPIENTS=${EMAIL_RECIPIENTS}" >> email_properties

And then, in the post-build action, I used Trigger parametrized build on other projects , with the Parameters from properties file option in order to trigger some other job whose only purpose is to email me those credentials. It's a bit of a work around, but it works.

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