Jenkins remote application deployment

Jenkins is an opensource continuous delivery and integration server application. You can use it for a variety of purposes such as building your application from version control system, deploy it on different environments or running acceptance tests. In this tutorial we will learn how you can use Jenkins to deploy remotely your application to a WildFly / JBoss EAP server.

The simplest way to perform a remote deployment with WildFly or JBoss EAP in an integrated way is by means of Maven plugin. This plugin is configurable to that you can define the target server as a System Property that can be in turn  injected from Jenkins. Let's see in detail.

Configuring WildFly / JBoss EAP Maven plugin

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

<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>administrator</username>
      <password>Password1!</password>
   </configuration>
</plugin>

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

<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>administrator</username>
      <password>Password1!</password>
   </configuration>
</plugin>

Configuring Jenkins to use the Maven plugin

Configuring Jenkins to run the WildFly or JBoss plugin is trivial. Just create a new Maven project, and pass to the goal as Property the hostname (or any other configurable attribute) so that Jenkins will drive the delivery of the application on a specific host:

jenkins remote deploy

That's all! build the Jenkins Item and check that the deployment was succesfull:

[INFO] XNIO version 3.2.2.Final
[INFO] XNIO NIO Implementation Version 3.2.2.Final
[INFO] JBoss Remoting version 4.0.3.Final
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.510 s
[INFO] Finished at: 2016-08-17T18:37:09+02:00
[INFO] Final Memory: 25M/238M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /home/francesco/maven-projects/wildfly10/quickstart-10.x/helloworld/pom.xml to org.wildfly.quickstarts/wildfly-helloworld/10.0.0-SNAPSHOT/wildfly-helloworld-10.0.0-SNAPSHOT.pom
[JENKINS] Archiving /home/francesco/maven-projects/wildfly10/quickstart-10.x/helloworld/target/wildfly-helloworld.war to org.wildfly.quickstarts/wildfly-helloworld/10.0.0-SNAPSHOT/wildfly-helloworld-10.0.0-SNAPSHOT.war
channel stopped
Finished: SUCCESS

Follow us on Twitter