Yiyito
2018-12-03 15:09:13 UTC
Hello guys, IÂŽm not sure how does POM in maven works correctly. Here is the
thing. I was able to create a job with Jenkins Which build & publish a WAR
from java code, to Artifactory using maven (with artifactory plug in) with
job number at the end to keep versioning .Then a maven-metadata.xml is
created on artifactory as showed in first pic (check attach)
After that, on a second job for deploy, with build with parameters option,
I choose artifact selected and deploy the number of war I want like this
(check second image arti2).
Now I wanted to do the same but using maven to ZIP just a folder and
publish to artifactory. I was able to do that with maven assembly plug in
successfully using a POM and a zip.xml file. Thing is that the metadata.xml
in artifactory is not generated like the job with a WAR file I mention at
the beginning. It only generates the zip file (also a jar) but not
metadata.xml which is needed so I can use jenkins to choose Zip file. here
is image from artifactory of Zip generated and error I receive from jenkins
(check third image)
So question is, how does POM generates this metadata.xml file in
artifactory? I used same pom of Java project that was used to build and
publish WAR, except that on last part part I included in <plugin> section
"maven assembly plugin" to zip file. In fact , Zip was successfully
uploaded and created as I showed on image . Here is POM and zip.xml but
metadata.xml not. Anybody knows what can be the issue? thanks!
POM
<?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>
JENKINSFILE.
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://***@bitbucket.org/xxxxxxx/goproject'
}
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()
}
thing. I was able to create a job with Jenkins Which build & publish a WAR
from java code, to Artifactory using maven (with artifactory plug in) with
job number at the end to keep versioning .Then a maven-metadata.xml is
created on artifactory as showed in first pic (check attach)
After that, on a second job for deploy, with build with parameters option,
I choose artifact selected and deploy the number of war I want like this
(check second image arti2).
Now I wanted to do the same but using maven to ZIP just a folder and
publish to artifactory. I was able to do that with maven assembly plug in
successfully using a POM and a zip.xml file. Thing is that the metadata.xml
in artifactory is not generated like the job with a WAR file I mention at
the beginning. It only generates the zip file (also a jar) but not
metadata.xml which is needed so I can use jenkins to choose Zip file. here
is image from artifactory of Zip generated and error I receive from jenkins
(check third image)
So question is, how does POM generates this metadata.xml file in
artifactory? I used same pom of Java project that was used to build and
publish WAR, except that on last part part I included in <plugin> section
"maven assembly plugin" to zip file. In fact , Zip was successfully
uploaded and created as I showed on image . Here is POM and zip.xml but
metadata.xml not. Anybody knows what can be the issue? thanks!
POM
<?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>
JENKINSFILE.
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://***@bitbucket.org/xxxxxxx/goproject'
}
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()
}
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/43f0c09b-a587-406e-ad20-23d50d28b65c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/43f0c09b-a587-406e-ad20-23d50d28b65c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.