gpt4 book ai didi

java - 使用 Jenkins JBoss 插件

转载 作者:行者123 更新时间:2023-12-01 04:52:41 27 4
gpt4 key购买 nike

我真的找不到如何使用Jenkins 的 jboss 插件。我经历了一些显而易见的事情,但例如我不知道如何使用该组件、添加哪些属性等。

我想部署一个 EAR 和多个 WAR,即使启动 JBoss 也有问题。我意识到 JBoss 7 无法运行,它只支持早期版本。我明白了,我把超时设置为 15 秒。

最佳答案

我只能用 ANT 来解决这个问题。我希望这对下一个认为 Jenkins 的 jboss 插件可以工作的人有所帮助……它肯定不适用于 v7.1.1。

解决方法:

检查 JBoss 是否响应

  <condition property="jboss.online">
<socket server="localhost" port="8080"/>
</condition>

如果是,停止 JBoss 并删除所有部署

<target name="stop" depends="-check-status" if="${start.successful}">
<java jar="${jboss.home}/jboss-modules.jar" fork="true">
<arg line="-mp ${jboss.home}/modules org.jboss.as.cli -c command=:shutdown" />
</java>

<sleep seconds="10" />
<delete quiet="false" includeEmptyDirs="true">
<fileset dir="${jboss.home}/standalone/deployments/">
<include name="**/*" />
</fileset>
</delete>
</target>

将所有耳朵和 war 复制到部署

            <copy file="${publish.dir}/main.ear" overwrite="true" todir="${jboss.home}/standalone/deployments" />
<copy file="${publish.dir}/first.war" overwrite="true" todir="${jboss.home}/standalone/deployments" />
<copy file="${publish.dir}/second.war" overwrite="true" todir="${jboss.home}/standalone/deployments" />

启动 JBoss

<exec executable="${jboss.home}/bin/standalone.bat" spawn="true">

等待部署并开始单元测试

<!-- startup, deploy -->
<target name="deploy-war" description="deploy war file" depends="-start">
<condition property="jboss.online">
<socket server="localhost" port="8080"/>
</condition>

<echo message="${jboss.online}"> ONLINE STATUS</echo>
<sequential>
<echo>WAITING FOR DEPLOYMENT...</echo>
<waitfor>
<or>
<available file="${jboss.home}/standalone/deployments/main.ear.deployed" />
<available file="${jboss.home}/standalone/deployments/main.ear.failed" />
</or>
</waitfor>
<condition property="deployed">
<available file="${jboss.home}/standalone/deployments/main.ear.deployed" />
</condition>

<antcall target="deploy.failed"/>
<antcall target="deploy.success"/>

<echo>+----------------------------+</echo>
<echo>| W A R D E P L O Y E D |</echo>
<echo>+----------------------------+</echo>

</sequential>
</target>

<!-- Deploy success, run unit tests -->
<target name="deploy.success" if="deployed">
<echo>DEPLOY SUCCESS</echo>
<sleep seconds="10" />
<antcall target="unit-test.-multi-only-unit-test-noreport"></antcall>
</target>

<!-- Deploy failed, fail -->
<target name="deploy.failed" unless="deployed">
<echo>DEPLOY FAILED</echo>
<fail/>
</target>

如果出现任何失败,则调用 ant 错误,因此 Jenkins 将发送有关该错误的邮件。

当我重构代码时,我将发布最终版本

关于java - 使用 Jenkins JBoss 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14704558/

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