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

久未见 提交于 2019-12-04 19:16:03

问题


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?


回答1:


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.




回答2:


I have Jenkins running on a server inside Glassfish, running as the local system account, as it was installed, by using a derivation of this blog post, and I was able to get it to work by setting property variables in the "system configuration" (Jenkins Environment Injector Plug-in) in Jenkins. (BDS, BDSCOMMONDIR, FrameworkDir, FrameworkSDKDir etc...)

Then the trick for Delphi to pick up the appropriate path is to send the command line parameter "Win32LibraryPath" to MSBuild. Make sure to escape your double quotes in this parameter in Jenkins or else you will pull out your hair.




回答3:


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 !




回答4:


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.


来源:https://stackoverflow.com/questions/5735241/why-is-jenkins-ignoring-the-path-variable-when-using-msbuild

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