Deploy war file to JBoss EAP or Wildfly from Jenkins

Last time I had to scratch my head to find out someway to deploy war I’m generating after running

mvn clean install

Some plugins are having some issues, sometimes JBoss is not configured to accept public connection or sometimes when using native management the port is blocked with firewall rule.

To deploy a war file to JBoss EAP or Wildfly server from Jenkins we can use any one of the following methods. Firstly if maven is supposed to generate the war file in target folder, we need to make sure that Jenkins is not doing a cleanup before deployment is done. Once this step is check lets dive into it.

The Simplest Way (With SSH):

One cool thing with JBoss server is if you place a war file under <JBoss_intall_dir>/standalone/deployment directory. The server will automatically explode the war and deploy it (provided you have not disabled it explicitly). The first approach depends on this feature.

We can use the Publish Over SSH plugin to transfer the artifact generated to the host where JBoss is running from Jenkins server. Then just add a new step

Add build step

The steps to configure this plugin are clearly documented in the link. So I won’t go into detail of that, rather I’ll explain when this will not be successful.

  1. If you are redeploying an artifact you need to make sure either filename of last version and current version is same or you need to manually delete the old artifact. Because JBoss server will not automatically undeploy the old artifact. Now if the new version is trying to aquire same context path, deployment will fail.
  2. If your artifact is taking logs after acquiring lock over a location the lock should be released. If that is not possible (most of the time it is not) you need to restart the JBoss server. Luckily SSH Plugin comes to rescue. Or the JBoss Management Plugin. Personally I preferred the SSH plugin


Via Wildfly Maven Plugin (If Maven Project):

This approach is not Jenkins specific. In this way you can deploy from your development machine as well as any other host with maven support. Just with

mvn install wildfly:deploy

Now to configure this we need to modify our pom.xml to add wildfly plugin. So lets add the following snippet inside of plugins sections of your pom file

Once added lets invoke maven goal specifying the parameters to find out this is working or not.

mvn package wildfly:deploy -Dhostname=localhost -Dport=9999 -Dusername=admin -Dpassword=password -Dfilename=yourArtifactId.war

Now some points are to be noted here:

  1. If you do not supply anything with hostname, by default it will take localhost.
  2. The port number should be of native management interface, not HTTP management interface.
  3. The credentials should be of Application User, not management user

Now to enable native management we need to do a small modification in standalone.xml. In the socket-binding-group node add the following line

<socket-binding name="management-native" interface="management" port="${}"/>

And in the management-interfaces section add the following element

<native-interface security-realm="ManagementRealm">

  <socket-binding native="management-native"/>


At this point everything works just perfect.

Actually there is another way with Jenkins Wildfly Deployer Plugin. But seriously I never got it working perfectly. The setup documentation says I need to copy some jars manually. Whenever there is such step I’m always a bit skeptical and somehow the plugin never worked for me 😛 even after adding all the jars mentioned. Some jar version mismatch was always there

But the others worked. So I had to be happy with the other two.

5 comments for “Deploy war file to JBoss EAP or Wildfly from Jenkins

  1. S
    January 13, 2017 at 1:09 am

    Wildly Jenkins plugin doesn’t work for anybody

  2. Felipe
    March 14, 2018 at 9:58 am

    Great post! Thanks for it!
    Just a small fix: in your example you put -Dflename=yourArtifactId.war (typo in flename) and it should be -Dfilename=yourArtifactId.war.

    Very useful post!

    • April 9, 2018 at 7:22 pm

      Thanks. Changed it.

      • sri kanth
        April 23, 2019 at 2:54 pm

        Great Post Very Use full …!

    November 21, 2018 at 2:07 am

    This didn’t work for me,

    Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:2.0.0.Final:deploy (default-cli) on project natums-core: Execution default-cli of goal org.wildfly.plugins:wildfly-maven-plugin:2.0.0.Final:deploy failed: java.nio.file.NoSuchFileException: /home/tales/Documents/Projetos/nat-webapp.war -> [Help 1]

Leave a Reply

Your email address will not be published.