Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 system cannot find the file specified

I've already had a similar issue on Ubuntu Server and resolved it by adding the path to the folder with the binaries installed globally by Composer to the PATH variable in Jenkins config (Manage Jenkins -> Configure System -> Global properties -> Environment variables: name=PATH, value=$PATH:$COMPOSER_HOME/vendor/bin/):

enter image description here

(Due to a permissions moving COMPOSER_HOME outside of the /root directory was also needed to another one, accessible for Jenkins, was also needed.)

Now I tried the same on Windows, but it doesn't work. So, maybe I'm just setting the PATH wrong. What I've tried:

PATH $PATH:D:\path\to\COMPOSER_HOME\vendor\bin  PATH $PATH;D:\path\to\COMPOSER_HOME\vendor\bin  PATH %PATH%D:\path\to\COMPOSER_HOME\vendor\bin  PATH %PATH%;D:\path\to\COMPOSER_HOME\vendor\bin 

How to set the PATH environment variable in Jenkins configs correctly working on Windows?

like image 333
automatix Avatar asked Apr 07 '16 10:04

automatix


People also ask

How use Jenkins environment variable in Windows batch command?

In Jenkins, go to the Build section of your project's configuration. Depending on the platform where your project executes, add either a Windows batch command (Windows) or a shell (UNIX) build step. This sets the following environment variables - COBDIR, PATH, CLASSPATH and LD_LIBRARY_PATH (or LIBPATH on AIX).

How do I find the PATH in Jenkins?

For me, setting an environment variable in Jenkins at /configure works BUT watch out for these: 1) /systemInfo will show the old PATH, 2) the job itself will show PATH = $PATH:/new/path & will not be expanded, even though it is during runtime, 3) echo $PATH in the freestyle job will show the wrong path.


2 Answers

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.

like image 136
Roderick Avatar answered Sep 22 '22 20:09

Roderick


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

like image 22
automatix Avatar answered Sep 24 '22 20:09

automatix