Jenkins使用Deploy to container Plugin自动部署项目到JBoss 7 Docker容器(成功版)

由于项目需要,需要有时候能有一个备份环境去启动JBoss 7的Docker容器,为了方便自动化部署,特别花了几天研究了标题中描述的方法。

步骤一:准备docker-compose.yml文件,基本如下(docker版本是17,并且Centos是7.3以上):

JBOSS_PASS是进入jboss后台界面的密码设置,默认用户名是admin,使用的镜像是pascalgrimaud的,具体看github

https://github.com/pascalgrimaud/docker-jboss-as

9999端口一定要打开,9990,9999,8080端口分别有不同用途,具体请自查

version: '2'

services:
  wildfly:
    image: pascalgrimaud/jboss-as:7.1.1
    hostname: 192.168.61.52
    ports:
      - '8280:8080'
      - '9990:9990'
      - '19999:9999'
    environment:
      JBOSS_PASS: 'niuren888'
    restart: "always"

步骤二:项目中pom.xml加入如下配置说明:

f you are using WildFly, just include in your pom.xml in the build section the following plugin:

1

2

3

4

5

6

7

8

9

10

11

<plugin>

   <groupId>org.wildfly.plugins</groupId>

   <artifactId>wildfly-maven-plugin</artifactId>

   <version>1.0.2.Final</version>

   <configuration>

      <hostname>${hostname}</hostname>

      <port>9990</port>

      <username>admini</username>

      <password>niuren888</password>

   </configuration>

</plugin>

 On the other hand, if you are using JBoss EAP or AS 7, then you have to use the following plugin:

1

2

3

4

5

6

7

8

9

10

11

<plugin>

   <groupId>org.jboss.as.plugins</groupId>

   <artifactId>jboss-as-maven-plugin</artifactId>

   <version>7.5.Final</version>

   <configuration>

      <hostname>${hostname}</hostname>

      <port>9990</port>

      <username>admin</username>

      <password>niuren888</password>

   </configuration>

</plugin>

步骤三,jenkins配置界面如下:

Jenkins使用Deploy to container Plugin自动部署项目到JBoss 7 Docker容器(成功版)

最后,通过#>docker logs -f 镜像ID前四位 ,这个命令查看相关jboos日志,如果部署成功,则说明整个环境运行成功。