How to set the PATH environment variable in Jenkins configuration on Windows?

前端 未结 7 497
我在风中等你
我在风中等你 2020-11-30 13:35

When I run my build process on Windows Server 2008, it fails with the error message like

Cannot run program \"foo\": CreateProcess: error=2, The syste

相关标签:
7条回答
  • 2020-11-30 14:00

    If you want to set it locally for the respective job try this in Build -> Execute batch Command step:

    //append more variables separated by ; if required
    SET Path=%PATH%;C:\Program Files\Git\bin;
    
    //run your command here
    git --version
    

    This approach works for any type of command you wanted to execute. Just add the respective environmental variable to the Path variable locally as shown above.

    0 讨论(0)
  • 2020-11-30 14:02

    don't get to confused about %PATH% vs $PATH in the Value field. While %PATH% is the correct syntax for windows nodes, you should use /foo/bar:$PATH to extend PATH on unix nodes

    0 讨论(0)
  • 2020-11-30 14:12
    • For adding path for Slave nodes, like home env variable.

    • It can be directory done from Slave nide configuration.

    • Open the configuration setting for any slave node, add env vaiable information.

    • For example for setting HOME just add the name and location of home directory.

    0 讨论(0)
  • 2020-11-30 14:15

    It needs to be "Path", not "PATH".

    Jenkins treats this special variable in a case-sensitive way, and only "Path" is recognized as being the path variable. "PATH" looks to jenkins like a generic environment variable, even on Windows.

    0 讨论(0)
  • 2020-11-30 14:20

    Couldn't get other it to work by the other answers. Ended up setting the variable in my slave node launcher (batch) script:

    SET PATH=C:\cygwin64\bin;%PATH%
    java -jar agent.jar -jnlpUrl ...
    
    0 讨论(0)
  • 2020-11-30 14:23

    The issue I had was caused not by a wrong Path configuration. %PATH%;D:\path\to\COMPOSER_HOME\vendor\bin is correct.

    enter image description here

    0 讨论(0)
提交回复
热议问题