Hudson可以为msbuild任务导出/设置/使用我的环境变量吗?

[英]Can Hudson export/set/use my environment variables for the msbuild task?


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

我在Vista上运行哈德森和调用的MSBuild对C ++的解决方案(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?

我可以通过hudson手动设置env变量,但我不想这样做 - 我想使用已经设置的现有变量。有没有办法做到这一点?

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.

基本上我希望能够从env变量列表中选择并告诉hudson映射/将它们导出到它产生的进程/工作空间。

Hudson is running as a service.

哈德森正在作为一项服务运行。

6 个解决方案

#1


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).

我只是通过下载最新版本的Hudson(1.316)进行快速测试,并创建一个只运行“set”的作业(如果你不熟悉这个,在控制台中自行运行set列出了所有的环境变量)目前的范围)。

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:

这是控制台输出,这些是所有环境变量 - 用户和系统,以及由Hudson自己定义的变量,以使Hudson元信息可用于作业:

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).

我怀疑你的变量根本没有在Hudson进程的所有者的环境中定义(或类似的东西,我们需要更多关于你的Hudson设置的信息才能真正了解)。


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.

编辑:另外注意,您可以查看/ systemInfo以查看Hudson可用的所有系统属性和环境变量。请记住,当Hudson生成一个新进程来完成工作时,所有环境变量都应该可供子进程使用,除非Hudson首先明确删除它们(我认为这比操作系统更像是Java的本质)。因此,除非你看到任何详细说明删除某些环境变量的文档(如果是这样,我确信开发人员有理由这样做),我首先要检查Hudson是否可以获得变量。 。

#2


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.

您可以尝试使用msbuild插件来避免整个环境设置问题。你只需要将插件指向msbuild的位置,它就可以从那里开始工作。

#3


Get what you need from here:

从这里得到你需要的东西:

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

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

#4


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

我遇到了同样的问题。我正在使用MSBuild插件,我的msbuild项目文件是:

<?xml version="1.0" encoding="Windows-1252"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&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 :

此文件在控制台中工作,在hudson输出中:

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\ __________________________________________________

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...

但我的构建失败,因为INCLUDE路径没有传递抛出MSBuild任务...

#5


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.

构建和批处理文件是两个单独的东西,批处理文件吃掉从构建生成的所有错误,与将文件发送到批处理文件时的其他方式相同。

#6


Tim,

Hudson exports many parameters as environment-variables, for example:

Hudson将许多参数导出为环境变量,例如:

BUILD_ID=2012-03-19_12-43-52
BUILD_NUMBER=74
HUDSON_HOME=C:\Documents and Settings\john\.hudson

As of Hudson v2.0.1 you also have the Hudson-User who initiated the build:

从Hudson v2.0.1开始,你也有Hudson-User发起了构建:

HUDSON_USER=dan

Complete list of environment variables is here: Hudson Set Environment Variables

完整的环境变量列表如下:Hudson Set Environment Variables

If you wish to pass other parameters to your job, the best way is to use Hudson's Parameterized Build

如果您希望将其他参数传递给您的工作,最好的方法是使用Hudson的参数化构建

Just note that for Windows you should use the convention "%MY_PARAM%" (instead if "$MY_PARAM" on Unix).

请注意,对于Windows,您应该使用约定“%MY_PARAM%”(而不是Unix上的“$ MY_PARAM”)。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2009/07/17/8c606ac41c15d792aae94fb9e986d0c9.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告