views:

2344

answers:

5

I am running hudson on Vista and calling MSBuild for C++ solutions (VS 2008).

I have not been able to find a way to export the existing user or system environment variables.

I can manually set env variables via hudson, but I prefer not to do that - I want to use the existing ones that are already set. Is there a way to do this?

Essentially I want to be able to pick from a list of env vars and tell hudson to map those/export those to the processes/workspaces it spawns.

Hudson is running as a service.

+3  A: 

You might try the msbuild plugin to avoid the whole environment setup issue. You just have to point the plugin to the location of msbuild, and it all works from there.

Michael Donohue
I tried the msbuild plugin. After fighting with teh setup for it I got it to run, but I have the same problem. My SLN/vcproj projects rely on env vars for some include paths. Those are not getting exported to teh msbuild workspace by hudson.
Tim
A: 

Build and batch files are two separate things, the batch file eats all the errors that are generated from build, same with other way when you send input to batch file.

Broken Link
Could you clarify this? What do you mean, 'the batch file eats all the errors generated from the build' ?
Michael Donohue
I think he means that hudson won't know about the output of errors, etc. That is good information, but nothing to do with the issue I have.
Tim
+1 - doesn't deserve a downvote
Tim
yeah, it is difficult to figure out, but I appreciate anyone trying to help me out.
Tim
+2  A: 

Get what you need from here:

%comspec% /k ""h:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86

kenny
I am not sure what you mean by that. Does that mean calling my bat file using that %comspec% thingie will solve my env vars not working?
Tim
If you go look at that batch file, it has all of the SETs you need in there.
kenny
The question originally seemed to be asking about VS environment variables. Further clarification indicates it is about getting custom build environment variables to appear in the environment.
Michael Donohue
+2  A: 

I just did a quick test by downloading the latest version of Hudson (1.316), and creating a job that runs simply "set" (if you're not familiar with this, running set by itself in the console lists all the environment variables within the current scope).

Here's the console output, these are all the environment variables - user and system, plus variables defined by Hudson itself to make the Hudson meta information available to the jobs:

Started by user anonymous
[workspace] $ cmd /c call D:\Temp\hudson5023210513071219278.bat

C:\Documents and Settings\jack\.hudson\jobs\Environment Variable Test\workspace>set
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\jack\Application Data
BUILD_ID=2009-07-19_22-59-42
BUILD_NUMBER=1
BUILD_TAG=hudson-Environment Variable Test-1
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=BEEBLEBROX
ComSpec=C:\WINNT\system32\cmd.exe
EXECUTOR_NUMBER=0
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\jack
HUDSON_COOKIE=a0bc798a-20ab-40bc-aad6-f4a331567999
HUDSON_HOME=C:\Documents and Settings\jack\.hudson
JAVA_HOME=c:\program files\java\jdk1.6.0
JOB_NAME=Environment Variable Test
LOGONSERVER=\\BEEBLEBROX
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Os2LibPath=C:\WINNT\system32\os2\dll;...blah...blah...blah...
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 15 Stepping 0, AuthenticAMD
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0f00
ProgramFiles=C:\Program Files
PROMPT=$P$G
QTJAVA=C:\Program Files\Java\jre1.6.0\lib\ext\QTJava.zip
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=D:\Temp
TMP=D:\Temp
USERDOMAIN=BEEBLEBROX
USERNAME=jack
USERPROFILE=C:\Documents and Settings\jack
windir=C:\WINNT
WORKSPACE=C:\Documents and Settings\jack\.hudson\jobs\Environment Variable Test\workspace

C:\Documents and Settings\jack\.hudson\jobs\Environment Variable Test\workspace>exit 0 
Finished: SUCCESS

I suspect your variables are simply not defined within the environment of the owner of the Hudson process (or something like that, we'll need more information about your Hudson set up to really know).


Edit: Another note, you can have a look at /systemInfo to see all the system properties and environment variables that are available to Hudson. Keep in mind that when Hudson spawns a new process to do work, all environment variables should be available to the child process, unless Hudson explicitly remove them first (this is more a nature of the operating system than Java, I believe). So unless you see any documentation detailing the removal of certain environment variables (and if so, I'm sure the developers would have a reason for it), I'd first check to see if the variables are available to Hudson in the first place.

Jack Leow
I'll look into that. I thought I had the process configured correctly.
Tim
A: 

I got the same probleme. I'm using the MSBuild plugin, my msbuild project file is :

<?xml version="1.0" encoding="Windows-1252"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003&quot;&gt;
<Target Name="FooCompilation">
<Message Text="INCLUDE: $(INCLUDE)"/>
<Message Text="LIB: $(LIB)"/>
<Message Text="PATH: $(Path)"/>
<MSBuild Projects="Proj1.vcproj" Properties="Configuration=Release" />
</Target>
</Project>

This file work in console, in hudson output :

Target FooCompilation: INCLUDE: "C:\Program Files\Microsoft SDKs\Windows\v6.1\Include" LIB: "C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib" PATH: "C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin";C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\ ____________________________

But my build failed because INCLUDE path not pass throw MSBuild Task...

max