我想通過在Jenkins的工作中使用maven antrun插件啓動Tomcat。我知道我可以使用貨物,但我無法使用它。原因是我想在構建完成後運行應用程序的Tomcat。Jenkins沒有運行通過maven-antrun的Catalina.bat
這裏是場景 - 我有Job 1,它檢出一個項目 - >構建它 - >在Tomcat上部署它。 另一個工作說,作業2檢出另一個項目 - >在ESB上構建並部署它,然後使用部署在作業1上的Tomcat運行集成測試。 我需要在作業1中停止一次Tomcat,而使用貨物:stop在清理階段 - 那麼我打算在編譯階段之後使用maven antrun來啓動它。然後再使用貨物在包裝階段後重新部署新的戰爭。我需要這樣做,以便Tomcat刷新每個測試版本,並且不會受Permgen等影響。
無論如何,問題是我的以下腳本從我的命令提示符運行正常,即它啓動Tomcat罰款並打開命令窗口爲Startup.bat。但是當我在Jenkins中嘗試相同的時候,它不會被執行並且足夠有趣,它不會發出抱怨 - 簡單的不會啓動tomcat。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>startTomcat</id>
<phase>compile</phase>
<configuration>
<target>
<exec executable="C:\Windows\System32\cmd.exe" spawn="true">
<arg value="/c" />
<arg value="D:\apache-tomcat-6.0.36\bin\startup.bat" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
的是我在詹金斯
[INFO] Executing tasks
Build sequence for target(s) `main' is [main]
Complete build sequence is [main, ]
main:
[exec] Current OS is Windows 7
[exec] Executing 'C:\Windows\System32\cmd.exe' with arguments:
[exec] '/c'
[exec] 'D:\apache-tomcat-6.0.36\bin\startup.bat'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
Execute:Java13CommandLauncher: Executing 'C:\Windows\System32\cmd.exe' with arguments:
'/c'
'D:\apache-tomcat-6.0.36\bin\startup.bat'
The ' characters around the executable and arguments are
not part of the command.
spawned process [email protected]
[INFO] Executed tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(startTomcat)
我曾經嘗試都可執行= 「C:\ WINDOWS \ SYSTEM32 \ cmd.exe的」 查看日誌以及可執行= 「CMD.EXE」 - 同樣的問題,即從命令提示符運行時,它工作正常,但在詹金斯這不是啓動tomcat,都沒有出錯。
已檢查Jenkins - 系統配置和user.name是NEW-LT7-0064 $。 不知道這是否有什麼幫助,但是當我從命令提示符運行用戶是我的Windows登錄用戶。 另外我使用本地系統帳戶將Jenkins作爲Windows服務運行。
我嘗試以下,以及在鏈路https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build建議,並沒有在Windows 64位的Windows 7機器
Another workaraund for Windows XP and later is to shedule permanent task and force running it from the ant script.
Once run the command:
C:\>SCHTASKS /Create /RU SYSTEM /SC ONSTART /TN Tomcat /TR "C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\startup.bat"
Note, that ONSTART can be replaced with ONCE if you do not want to keep Tomcat running.
Add the following code to your ant script:
<exec executable="SCHTASKS">
<arg value="/Run"/>
<arg value="/TN"/>
<arg value="Tomcat"/>
</exec>
嗨唐。是的,我檢查了tomcat沒有啓動。我查看了Tomcat的啓動日誌,沒有發生任何事情。好的,我會探討一下,如果我可以控制tomcat作爲一項服務 - 但上述問題仍然存在。爲什麼Jenkins無法執行bat文件作爲Maven構建的一部分,該構建可以在命令提示符maven構建中正常運行。必須與user.name的權限/路徑有關,這是我的懷疑。有什麼想法嗎? – Soumya
僅供參考..我嘗試了這裏的選項https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller(從上面發佈的鏈接中找到)。似乎已經爲一些工作,但沒有爲我工作:-( – Soumya