java - 使用 Jenkins JBoss 插件

标签 java jboss jenkins

我真的找不到如何使用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/

相关文章:

java - 卡在 JBOSS Ticket Monster 添加 Arquillian 中

jenkins - 为Jenkins安装和设置BlueOcean

Jenkins 和 Gradle : Unable to get environment variables

git - 无法解析 docker 中的主机

java - 构建 Java derby 项目的 jar 文件时出错

java - 在线程内调用 MessageBox

大字节的java Inputstream然后是127

java - 如何使用 PBE 算法解密字符串

maven - Dockerfile启动JBoss CLI失败

java - 在 websphere 中导致的日期格式问题