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
