使用Jenkins JBoss插件

时间:2013-02-05 09:53:37

标签: java jboss jenkins

我无法真正找到如何使用 Jenkins的jboss插件。我经历了很明显的事情,但是例如我不知道如何使用组件,添加什么属性等。

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

1 个答案:

答案 0 :(得分: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将发送有关错误的邮件。

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