1

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

我想部署一个 EAR 和多个 WAR,即使启动 JBoss 也有问题。我意识到 JBoss 7 不会运行,它只是支持早期版本。我明白了,我遇到了 15 秒的超时。

4

1 回答 1

0

我只能用 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>

将所有耳朵和战争复制到部署中

            <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 将发送有关错误的邮件。

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

于 2013-02-07T14:09:10.710 回答