我在哈德森有一個使用maven構建的項目。它編譯C++源代碼以創建一個可用於項目其他部分的可執行文件。它使用Visual Studio工具,特別是造成麻煩的工具。當它試圖加載midl程序時,它找不到它。如果我登錄到服務器是我哈德森的生活,並嘗試MVN潤潔在那個特定項目安裝,我得到:在Hudson中使用Maven和C++項目無法獲得構建成功
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] ------------------------------------------------------------------------
但這並不時自動生成的哈德森踢腿工作。我試圖加載該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實際使用我得到的構建失敗後,此輸出點:
[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]
我還設置環境變量對{VS100COMNTOOLS,C:\ APPS \ MicrosoftVisualStudi o-10.0 \ Common7 \ Tools}在Hudson配置面板中。我不知道還有什麼可以做的,任何幫助都會有所幫助。
我不是哈德森專家,但考慮用戶使用的操作系統用戶運行哈德森,也許你得到它的工作,因爲你使用不同的操作系統用戶?還要檢查一下.bat的功能,當你執行「pushd&popd」而不是當前shell時,是否可以在單獨的shell實例上設置一些東西? – gerrytan
@gerrytan謝謝,單獨的實例shell是一個很好的線索,我終於明白了。 – amaurs