Issue
I want Jenkins to run "Execute Windows batch command"
After run this, this command make a output with multiple lines. These rows will be used in next build step so that I want to save these to my Jenkins environment variables.
How can I save these value? If there is other way, let me know. Thanks!
Solution
Because each Execute Window Batch
or Execute shell
build step run in seperate sandbox, so any environment variable exported inside them will be destoried once step finish.
If you want those environment varabiles can be used accross step, you have to export then into file, then read the file back.
Step 1, generate a plain file with key = value pattern by Execute window batch
or 'Execute shell'
Step 2, add a Inject environment variable
build step, and specify above generated file, once this build step complete, those keys will be exportedinto the job building's environment variables set.
Step 3, you can use them by ${key} in windows batch or linux shell in subsequent build steps and any post actions
Answered By - yong
Answer Checked By - Marie Seifert (JavaFixing Admin)