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

发布于 2024-07-27 17:56:37 字数 257 浏览 4 评论 0 原文

我在 Vista 上运行 hudson 并调用 MSBuild 来获取 C++ 解决方案(VS 2008)。

我一直无法找到导出现有用户或系统环境变量的方法。

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

本质上,我希望能够从环境变量列表中进行选择,并告诉 hudson 将这些映射/导出到它生成的进程/工作空间。

Hudson 作为服务运行。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

遗忘曾经 2024-08-03 17:56:37

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

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.

小糖芽 2024-08-03 17:56:37

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

这是控制台输出,这些是所有环境变量 - 用户和系统,加上 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

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


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

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.

無心 2024-08-03 17:56:37

从这里获取您需要的内容:

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

Get what you need from here:

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

半世蒼涼 2024-08-03 17:56:37

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


<项目 xmlns="http://schemas.microsoft.com/developer/ msbuild/2003">;
<目标名称=“FooCompilation”>


<消息文本=“路径:$(路径)”/>
>

该文件在控制台中的 hudson 输出中工作:

目标 FooCompilation:
包括:“C:\ Program Files \ Microsoft SDKs \ Windows \ v6.1 \ Include”
LIB:“C:\ Program Files \ Microsoft SDKs \ Windows \ v6.1 \ Lib”
路径:“C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin”;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\Microsoft SQL服务器\90\工具\binn\
__________________________________________________

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

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

满天都是小星星 2024-08-03 17:56:37

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

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.

梦里人 2024-08-03 17:56:37

Tim,

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

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

从 Hudson v2.0.1 开始,您还拥有启动构建的 Hudson 用户:

HUDSON_USER=dan

环境变量的完整列表位于:Hudson 设置环境变量

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

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

Tim,

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

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_USER=dan

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文