简体   繁体   English

使用Jenkins和maven将WAR文件发布到Artifactory

[英]Using Jenkins and maven to publish a WAR file to Artifactory

I am attempting to configure the following workflow pattern in Jenkins: 我试图在Jenkins中配置以下工作流模式:

  1. Build WAR File & Publish to Artifactory 构建WAR文件并发布到Artifactory
  2. Deploy WAR File from Artifactory to DEV & Publish to Artifactory Repo for Dev 将WAR文件从Artifactory部署到DEV并发布到Artifactory Repo for Dev
  3. Deploy WAR File from DEV to QA & Publish to Artifactory Repo for QA 将WAR文件从DEV部署到QA并发布到Artifactory Repo以进行QA
  4. {QA to Regression and so on} {QA to Regression等}

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. 应用程序的组件(jar文件等)似乎在目标版本/快照目录中很好地部署到Artifactory。 However, the final WAR artifact doesn't seem to get stored in Artifactory despite Jenkins clearly identifying the artifact was successfully built. 但是,尽管Jenkins清楚地识别出工件已成功构建,但最终的WAR工件似乎并未存储在Artifactory中。

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. 我安装了Jenkins的标准Artifactory插件。

I have checked the following configurations for the first Jenkins Job to build the project and publish it to Artifactory: 我已经检查了第一个Jenkins作业的以下配置来构建项目并将其发布到Artifactory:

PRE-BUILD & BUILD 预建和建设

  • Discard Old Builds (keep 5) 丢弃旧版本(保留5)
  • Permission to copy artifacts 复制工件的权限
  • git (with requisite credentials which work properly) git(具有正常工作的必要凭据)
  • Enable Artifactory Release Management (One version for all modules) 启用Artifactory Release Management(所有模块的一个版本)
  • Build uses a POM and the "clean" and "install" options. Build使用POM和“干净”和“安装”选项。

POST-BUILD POST-BUILD

  • Archive the artifacts (**/*.war) 存档工件(** / * .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) 将工件部署到Artifactory(发布和快照目录存在并且似乎工作正常,并且在单击刷新时从Artifactory服务器正确加载)
  • 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. 我可以使用这些相同的选项,他们将成功地将最终的WAR文件部署到Tomcat实例而不会出现问题。 Jenkins also holds on to the WAR file based on configuration. Jenkins还根据配置保留了WAR文件。 But Artifactory seems to store the components instead of the final WAR file. 但Artifactory似乎存储组件而不是最终的WAR文件。

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. 编辑:这是构建war文件时用于“干净安装”目标的POM文件的snippit。

<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. 似乎War文件是Maven项目的第二个人工制品。

Can you have a look here and tell us if it solves your issue? 你能看一看并告诉我们它是否能解决你的问题吗? Maven deploy secondary file to repository Maven将辅助文件部署到存储库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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