Started by user unknown or anonymous
Running as SYSTEM
Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\test
[test] $ cmd /c call C:\Windows\TEMP\jenkins7973539064156672133.bat
C:\ProgramData\Jenkins\.jenkins\workspace\test>echo Hello
Hello
C:\ProgramData\Jenkins\.jenkins\workspace\test>echo ${BUILD_ID}
${BUILD_ID}
C:\ProgramData\Jenkins\.jenkins\workspace\test>exit 0
Finished: SUCCESS
As you can see, the build was successful, but the environment variable "BUILD_ID" value did not show.
In batch scripting you need to use %BUILD_ID%
syntax.