Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Jenkins ignoring the %PATH% variable when using MSBuild?

I am trying to use Jenkins to compile my MSBuild project created with Delphi. I have the MSBuild plugin installed into Jenkins and configured. I'm choosing the specific configuration for my build job.

I have set all the environmental variables in Jenkins that are required by the Delphi compiler (from rsvars.bat for you Delphi types.)

The project compiles just fine on the command line. If I do it on the command line, MSBuild reports a nice big fat PATH (the correct one) as part of the command line it uses to call the Delphi compiler.

However, when I try to use it with Jenkins, the result is quite different:

C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin\dcc32.exe -$D- -$L- -$Y- --no-config -B -Q -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DRELEASE -K00400000   HTMLWriterTestApp.dpr   
  Embarcadero Delphi for Win32 compiler version 22.0
  Copyright (c) 1983,2010 Embarcadero Technologies, Inc.

Noet the complete lack of a path, or any other information about were to find what the compiler needs. This information is there when I run from the command line.

Can anyone think of any reason why Jenkins is failing to get the correct PATH information?

like image 656
Nick Hodges Avatar asked Apr 20 '11 18:04

Nick Hodges


People also ask

How can you modify PATH variable in Jenkins master?

From "Global Properties -> Environment Variables" i add 2 entries: "PATH" with value "$PATH:/opt/foo" and "FOO" with value "BAR". Now when i run my free style job with execute shell build step being "echo $PATH; echo $FOO" i see that PATH was not modified whereby FOO is displayed correctly.

What is the use of Environment Variables in Jenkins?

What are Environment Variables in Jenkins? Environment variables are global key-value pairs Jenkins can access and inject into a project. Use Jenkins environment variables to avoid having to code the same values for each project. Other benefits of using Jenkins environment variables include improved security.


3 Answers

Depending on how you run Jenkins, it may not have the full path line that you are used to seeing. For example, if you run Jenkins as a Windows Service and have your USERS PATH variable populated, you won't necessarily have it populated for the SYSTEM user. In this case, modify the Logon Account used by the Service to be your account, rather than a system one.

like image 97
Jason Swager Avatar answered Oct 23 '22 09:10

Jason Swager


Anything with git pull/ where git commands, which are not executing from Jenkins is because of the path issue in the environmental variables in Windows.

  1. Check the PATH in Environment variables.
  2. Check the same command executes from windows command prompt or not.
  3. If it is executing & Windows is running as slave service, then restart the slave service from services.msc.
  4. Log out and login back to Jenkins.
like image 41
Chaitanya T Avatar answered Oct 23 '22 11:10

Chaitanya T


I had Jenkins started as windows service and it could not find an SVN command even if I had SVN\bin in my PATH variable for the System user.

It seems that the service uses only the environment variables available at start up time. So if later on you add some more environment varibales to the Windows System user, they will not be available to the service. All you have to do is restart the window service and it will pick the new environment variables !

like image 33
ntumba Avatar answered Oct 23 '22 10:10

ntumba