Forked from robertobatts/JenkinsfileMavenArtifactory.groovy
Created
April 22, 2021 03:51
-
-
Save naviat/7e3d414b03c5f9c3a062291914065b2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pipeline { | |
| agent any | |
| tools { | |
| jdk 'OpenJDK_1_8_0' | |
| } | |
| stages { | |
| stage ('Artifactory configuration') { | |
| steps { | |
| rtServer ( | |
| id: "server_tutorial", | |
| url: "http://3.134.8.172:8081/artifactory", | |
| credentialsId: "artifactory-credentials" | |
| ) | |
| rtMavenDeployer ( | |
| id: "MAVEN_DEPLOYER", | |
| serverId: "server_tutorial", | |
| releaseRepo: "libs-release", | |
| snapshotRepo: "libs-release" | |
| ) | |
| //with the resolver it doesn't work, I suppose it's because Artifactory doesn't support Maven3 | |
| /*rtMavenResolver ( | |
| id: "MAVEN_RESOLVER", | |
| serverId: "server_tutorial", | |
| releaseRepo: "libs-release", | |
| snapshotRepo: "libs-release" | |
| )*/ | |
| } | |
| } | |
| stage ('Build Maven') { | |
| steps { | |
| //set settings.xml with the ID of the config file on Jenkins | |
| configFileProvider([configFile(fileId: 'MavenArtifactorySettingId', variable: 'MAVEN_SETTINGS_XML')]) { | |
| retry(count: 3) { | |
| rtMavenRun ( | |
| tool: "Maven 3.6.2", // Tool name from Jenkins configuration | |
| pom: 'pom.xml', | |
| goals: '-U -s $MAVEN_SETTINGS_XML clean install', | |
| deployerId: "MAVEN_DEPLOYER"/*, | |
| resolverId: "MAVEN_RESOLVER"*/ | |
| ) | |
| } | |
| } | |
| } | |
| } | |
| stage ('Publish to Artifactory') { | |
| steps { | |
| rtPublishBuildInfo (serverId: "server_tutorial") | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment