简体   繁体   中英

Using Jenkins and maven to publish a WAR file to Artifactory

I am attempting to configure the following workflow pattern in Jenkins:

  1. Build WAR File & Publish to Artifactory
  2. Deploy WAR File from Artifactory to DEV & Publish to Artifactory Repo for Dev
  3. Deploy WAR File from DEV to QA & Publish to Artifactory Repo for QA
  4. {QA to Regression and so on}

I seem to be missing something. The components of the application (jar files, etc.) appear to get deployed to Artifactory just fine in the target releases/snapshots directories. However, the final WAR artifact doesn't seem to get stored in Artifactory despite Jenkins clearly identifying the artifact was successfully built.

I'm using the standard targets: clean install. I have also attempted (with no change): clean install repackage

I have the standard Artifactory plugin for Jenkins installed.

I have checked the following configurations for the first Jenkins Job to build the project and publish it to Artifactory:

PRE-BUILD & BUILD

  • Discard Old Builds (keep 5)
  • Permission to copy artifacts
  • git (with requisite credentials which work properly)
  • Enable Artifactory Release Management (One version for all modules)
  • Build uses a POM and the "clean" and "install" options.

POST-BUILD

  • Archive the artifacts (**/*.war)
  • Deploy artifacts to Artifactory (release and snapshot directories exist and seem to work fine, and are loaded from the Artifactory server properly when I click refresh)
  • Capture & Publish Build Info
  • Include Environment Variables (only the defaults configured)

An editable email notification post-build step is also included.

I can use these same options and they will successfully deploy the final WAR file to a Tomcat instance without issue. Jenkins also holds on to the WAR file based on configuration. But Artifactory seems to store the components instead of the final WAR file.

I've been playing with config options and coming up blank for too long. Any and all help is appreciated.

EDIT: Here is a snippit from the POM file used for the "clean install" target when building the war file.

<build>
    <defaultGoal>clean install</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <includes>
                    <include>**/*Tests.java</include>
                    <include>**/*Test.java</include>
                    <include>**/Test*.java</include>
                </includes>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven.war.plugin.version}</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                    <addMavenDescriptor>false</addMavenDescriptor>
                    <manifestEntries>
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Implementation-Revision>${git.revision}</Implementation-Revision>
                        <X-Git-Commits-Count>${git.commitsCount}</X-Git-Commits-Count>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <autoVersionSubmodules>true</autoVersionSubmodules>
            </configuration>
        </plugin>
    </plugins>
</build>

It seems that the War file is the second artefact of your Maven project.

Can you have a look here and tell us if it solves your issue? Maven deploy secondary file to repository

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