This post is older than a year. Consider some information might not be accurate anymore.
The maven deploy plugin allows to deploy artifacts and files to your internal repository. If you happen to have a Maven Repository like Sonatype Nexus or JFrog’s Artifactory the plugin is the right choice. This post covers how to deploy a rpm file to Artifactory. The Maven repository itself is not covered here.
First you have to define in your maven project (pom.xml) the deploy-file goal. Replace the properties. Following example is for a rpm generated file with Apache Maven.
<build>
<plugins>
<!-- deploy rpm to artifactory -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<!-- must match id of settings.xml of Jenkins -->
<repositoryId>artifactory</repositoryId>
<url>${deployment.repository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${rpm.version}-${rpm.release}.noarch</version>
<file>${rpm.copy.to.location}</file>
</configuration>
</plugin>
</plugins>
</build>
Artifactory itself may have a snapshot and release repository, which is expressed through two maven profiles (test and prod).
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<deployment.repository.url>https://artifactory.cinhtau.net/artifactory/yum-snapshot-local
</deployment.repository.url>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<deployment.repository.url>https://artifactory.cinhtau.net/artifactory/yum-release-local
</deployment.repository.url>
</properties>
</profile>
</profiles>
After the rpm is generated, deploy your rpm within the Jenkinsfile to production if you happen to be on the git master branch, otherwise put it the snapshot repository.
stage('Build: artifactory') {
if (isMaster) {
sh "${mvnHome}/bin/mvn rpm:version deploy:deploy-file --activate-profiles prod -Dbuild.number=${BUILD_NUMBER}"
} else {
sh "${mvnHome}/bin/mvn rpm:version deploy:deploy-file --activate-profiles test -Dbuild.number=${BUILD_NUMBER}"
}
}