Setting environment variables in Jenkins with a bat file?

浪子不回头ぞ 提交于 2021-02-07 14:20:55

问题


Currently I have a batch file that sets all the environment variables needed before starting the build process.

It's a must to use the same bat for setting the env variables.

I tried to use EnvInject Plugin, didn't have any success.

Also tried "Execute Windows batch command" before running msbuild. e.g. start mybat.bat - this didn't seem to work either

How can I integrate the same bat file to set the variables?


回答1:


Each Jenkins "build step" has it's own environment, I explained this in detail in this answer: Can not change Jenkins String Parameter Variable

If you are using the MSBuild plugin, it is its own build step, so using other build steps to change the environment is futile. If you are launching MSBuild through command line using "Execute Windows batch command", then just ran your bat file within the same build step, preceding the MSBuild command

In the case of MSBuild plugin, the only proper way is to use EnvInject plugin. Maybe you should try to figure out what isn't working for you with EnvInject plugin. From the example documentation, you want to be using "At job level" configuration, to populate your whole job with the variables from your .bat file.



来源:https://stackoverflow.com/questions/22357572/setting-environment-variables-in-jenkins-with-a-bat-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!