【问题标题】:Can't get Build Success with Maven and C++ project in Hudson无法在 Hudson 中使用 Maven 和 C++ 项目构建成功
【发布时间】:2012-12-30 04:35:56
【问题描述】:

我在 Hudson 有一个使用 maven 构建的项目。它编译 C++ 源代码以创建用于项目其他部分的可执行文件。它使用 Visual Studio 工具,特别是会导致问题的工具。当它试图加载 midl 程序时,它找不到它。如果我登录服务器是我的 Hudson 生活并尝试在该特定项目中运行 mvn clean install 我得到:

D:\Hudson\jobs\{project-name}>mvn clean install
.
.
.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.876s
[INFO] Finished at: Mon Jan 14 21:56:18 PST 2013
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (build-tlb) on project interop: Command execution failed.
Cannot run program "midl" (in directory "D:\Hudson\jobs\{project-name}"): CreateProcess error=2, The system cannot find the file specified ->     [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR]     [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

解决此问题的一种方法是加载 Visual Studio 工具:

D:\Hudson\jobs\{project-name}>%VS100COMNTOOLS%\vsvars32.bat
Setting environment for using Microsoft Visual Studio 2010 x86 tools.

之后我得到了一个干净的构建:

D:\Hudson\jobs\{project-name}>mvn clean install
.
.
.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.331s
[INFO] Finished at: Mon Jan 14 21:59:06 PST 2013
[INFO] Final Memory: 13M/222M
[INFO] ------------------------------------------------------------------------

但是当 Hudson 启动自动构建时,这不起作用。我尝试加载执行的 bat 文件 (vsvars32.bat):

pushd %VS100COMNTOOLS%
vsvars32.bat
popd

在我启动 maven 进程之前,我知道这是有效的,因为我在控制台输出中看到了这一点:

C:\Apps\MicrosoftVisualStudio-10.0\Common7\Tools>vsvars32.bat
Setting environment for using Microsoft Visual Studio 2010 x86 tools.

但是每当它到达实际使用 midl 的地步时,我都会在 BUILD FAILURE 之后得到这个输出:

[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler -     [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (build-tlb) on project interop: Command execution failed.
[DEBUG] Closing connection to remote

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (build-tlb) on project interop: Command execution failed. Cannot run program "midl" (in directory "D:\Hudson\jobs\{project-name}"): CreateProcess error=2, The system cannot find the file specified ->     [Help 1]

我还在 Hudson 配置面板中设置了环境变量对 {VS100COMNTOOLS,C:\Apps\MicrosoftVisualStudio-10.0\Common7\Tools}。我不知道还能做什么,任何帮助将不胜感激。

【问题讨论】:

  • 我不是 hudson 专家,但考虑一下曾经运行 hudson 的操作系统用户,也许你让它工作是因为你使用了不同的操作系统用户?还要检查 .bat 的作用,当您执行“pushd & popd”时,它是否可能在单独的 shell 实例上设置一些东西,而不是在当前 shell 上?
  • @gerrytan 谢谢,单独的实例外壳是一个很好的线索,我终于想通了。

标签: c++ maven hudson


【解决方案1】:

我终于想通了。 Hudson 调用新任务的方式是调用新的 cmd 窗口,以便将 %VS100COMNTOOLS%\vsvars32.bat 工具设置在不同的实例中。查看 %MAVEN_HOME%\bin 中的 mvn.bat 它可以让您在之前调用一个 bat 文件: 如果存在 "%HOME%\mavenrc_pre.bat" 调用 "%HOME%\mavenrc_pre.bat" 我在那里调用了 %VS100COMNTOOLS%\vsvars32.bat,所以每次我们运行 maven 时,也会加载可视化工具。尽管如此,Hudson 似乎并没有通过调用特定的 bat 文件来启动 maven 任务,它以某种方式创建了自己的 maven 实例,而忽略了 mavenrc_pre.bat。解决此问题的一种方法是将任务创建为不作为 Maven 任务,而是作为批处理任务并简单地调用: mvn 干净安装 这解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-20
    • 2011-07-12
    • 1970-01-01
    • 2016-02-02
    • 2012-04-25
    • 2010-12-21
    • 1970-01-01
    • 2016-05-25
    相关资源
    最近更新 更多