我不确定maven中的POM如何正常工作。这是东西。 我能够用Jenkins创建一个作业,该作业使用Java代码构建并发布WAR,并使用maven(带有人工插件)插入到Artifactory,最后带有作业编号以保持版本控制。然后在人工制品上创建了maven-metadata.xml。如下所示。
第二次工作之后,在jenkins中使用带有参数的构建选项,我选择了工件并像这样部署了我想要的战争次数
现在我想做同样的事情,但是使用maven将ZIP压缩为一个文件夹并发布到工件。我能够通过使用POM和zip.xml文件成功插入Maven程序集插件来做到这一点。问题是没有生成人工制品中的metadata.xml。它仅生成zip文件(也是jar),而不生成所需的metadata.xml,因此我可以使用jenkins选择Zip文件。这是从Zip的人为因素生成的图像,以及我从jenkins收到的错误:
问题是,POM如何在人工制品中生成此metadata.xml文件?我使用了与Java项目相同的pom,用于构建和发布WAR,除了在一部分上我将maven程序集插件包含到zip文件中,并且zip成功上传并创建后,如图所示。这是POM和zip.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.grey</groupId>
<artifactId>go</artifactId>
<version>${releaseVersion}</version>
<name>go</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<releaseVersion>0.0.0-SNAPSHOT</releaseVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这是zip.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>static</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
由于我正在处理此问题,目前尚不清楚,请寻求帮助。我不是开发人员,所以我对java和pom文件以及maven的了解不是最好的。谢谢您的帮助!
这是jenkinfile,用于将代码上传到工件。与Java应用程序相同。 仅有精简版更改的是项目中的存储库名称和命令“ package” 而不是“全新安装”
node {
def server = Artifactory.server 'azure-artifactory'
def rtMaven = Artifactory.newMavenBuild()
def buildInfo //= rtMaven.run pom: 'pom.xml', goals: 'clean install -D releaseVersion="${BUILD_NUMBER}"'
stage ('Code Checkout') {
git branch: 'devopstest',
credentialsId: '3e3c8889-0dcc-4b4d-bae1-ac140894d292',
url: 'ssh://git@bitbucket.org/xxxxx/xxxxxxx'
}
stage('Artifactory Configuration') {
// Tool name from Jenkins configuration
//rtMaven.tool = 'Apache Maven 3.0.5'
env.MAVEN_HOME = '/usr/share/maven/'
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
rtMaven.deployer server: server, releaseRepo: 'go-fe-maven-2'
}
stage('Maven build') {
//buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean install -D releaseVersion="${BUILD_NUMBER}"'
buildInfo = rtMaven.run pom: 'pom.xml', goals: 'package -D releaseVersion="${BUILD_NUMBER}"'
// rtMaven.deployer.deployArtifacts buildInfo
}
stage('Publish build info') {
// server.publishBuildInfo buildInfo
server.publishBuildInfo buildInfo
}
// Wipe the workspace so we are building completely clean
deleteDir()
}