gpt4 book ai didi

tomcat - Jenkins 没有通过 maven-antrun 运行 Catalina.bat

转载 作者:行者123 更新时间:2023-11-28 23:46:21 24 4
gpt4 key购买 nike

我正在尝试通过在 Jenkins 的作业中使用 maven antrun 插件来启动 Tomcat。我知道我可以使用 cargo 来做同样的事情,但我不能使用它。原因是我希望 Tomcat 在构建结束后运行应用程序。

场景如下 - 我有作业 1,它 checkout 一个项目 -> 构建它 -> 在 Tomcat 上部署它。另一个工作说 Job 2 检查另一个项目->构建并将其部署在 ESB 上,然后使用部署在 Job 1 上的 Tomcat 运行集成测试。我需要在作业 1 中停止 Tomcat 一次,这是我在清理阶段使用 cargo:stop 实现的——然后我计划在编译阶段后使用 maven antrun 启动它。然后再次使用 cargo 重新部署 package 阶段后的新 war。我需要这样做,以便为每个测试构建刷新 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>

这是我在jenkins看到的日志

[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 java.lang.ProcessImpl@ed11c1
[INFO] Executed tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(startTomcat)

我已经尝试了 executable="C:\Windows\System32\cmd.exe"以及 executable="cmd.exe"- 同样的问题,即当从命令提示符运行时它工作正常但在 jenkins 中这不是启动 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根本没有启动吗? IIRC Jenkins 不支持生成长期存在的构建过程(参见 here )。

关于tomcat second comment可能会有帮助:将 tomcat 作为服务而不是使用 shell 脚本启动。

关于tomcat - Jenkins 没有通过 maven-antrun 运行 Catalina.bat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13881255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com