我想通过在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