Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download WAR from snapshot-repository and deploy to local JBoss using mvn

currently I deploy my war with jboss:hard-deploy to my JBoss 6 AS. This works fine, but I have to checkout project from SVN and package it.

The war is already uploaded to our internal snapshot repository by Jenkins and it would be nice if I can download it on a testing server from this repository and directly deploy it to JBoss using maven.

This question is related to Maven deploy artifact war from repository to remote server, but I don't think the answer is correct (see the comment there).

like image 287
Thor Avatar asked Nov 28 '11 09:11

Thor


1 Answers

Ideally you would want to set up Jenkins to deploy to your testing server as part of your CI build.

Alternatively, if you want to manually run a script on the server you are deploying to, you could set up a specific pom.xml to perform this task. First setup the dependency plugin to download your war:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.3</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>my-group</groupId>
              <artifactId>my-web-archive</artifactId>
              <version>my-vesion</version>
              <type>war</type>
              <destFileName>my-web-archive.war</destFileName>
            </artifactItem>
          </artifactItems>
          <outputDirectory>${project.build.directory}</outputDirectory>
        </configuration>
      </execution>
    </executions>
  </plugin>

Substituting the group ID, artifact ID and version for the respective properties of your WAR file. Next configure the JBoss plugin to deploy the downloaded WAR:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jboss-maven-plugin</artifactId>
    <version>1.5.0</version>
    <configuration>
      <jbossHome>/opt/jboss-6</jbossHome>
      <serverName>all</serverName>
      <fileName>${project.build.directory}/my-web-archive.war</fileName>
    </configuration>
  </plugin>

You should then be able to download the artifact from your internal repository and deploy it in the locally running JBoss container with the following command:

mvn package jboss:hard-deploy
like image 135
orien Avatar answered Sep 24 '22 20:09

orien