简体   繁体   中英

Deploying Java EE Web App to Wildfly/JBoss EAP

More of a "what's best practice?" kind of question.

We have a number of Java EE web applications currently deployed manually through the web interface to JBoss EAP 7.0 application servers. I'm looking at automating these and have a simple Jenkins build which will deploy to our UAT environment using Jenkins promoted build plugins and the Wildfly maven plugin.

Whilst this is ok, we clearly have a defined "build" and "deploy" setup which i want to refine. My issue however is that when we run the "wildfly:deploy" goal, it's runs the maven install section of the build!

Essentially, deploying to different environments rebuilds the app, therefore we can't guarantee byte-for-byte parity with the build that was tested.

Is there a best practice way of deploying a built final release through environments using Jenkins/Maven onto JBoss EAP/Wildfly?

Thanks all!

I'm not sure why you need to deploy with Maven. Why not use the jboss-cli tool? With that you can do something like:

jboss-cli.sh --connect --command="deploy target/your.war --force"

This is the "localhost" version and it assumes you haven't created any users for Wildfly but it gives you an idea of what you can do. The CLI Docs get into different ways to deploy applications and expands greatly on the security aspect.

Jenkins can run a shell or batch script about as easily as it can run a maven build so this shouldn't be too difficult to implement in Jenkins.

Well in development workflow it is perfectly ok to deploy with maven, it saves time and context switching.

You can create a dedicated maven profile for deployment - this way you have the flexibility, either use maven just for build and deploy however you want, or run maven with your deploy profile, and let it do build+deploy.

Head over to Wildfly maven plugin for more info. It can do many tasks apart from deployment, including configuration tasks via jboss cli, but for the sake of deployment, this is all you need:

<profile
  <id>jboss-deploy</id>
  <build>
    <plugins>
      <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.2.1.Final</version>
        </plugin>
     </plugins>
  </build>
 </profile>

Now you can simply run mvn clean package -Pjboss-deploy and maven will compile and package your app, and then deploy the resulting war or ear to your running JBoss/Wildfly instance. You can also invoke the deployment manually via mvn wildfly:deploy

Have fun.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM