2017-07-15 7 views
1

私はMavenのビルドを駆動するためにJenkinsfileでartifactoryプラグインを使用しています:Artifactory Pluginでmavenローカルリポジトリパスを指定する方法は?

def goals = "clean install" 
def artifactory = Artifactory.server 'artifactory' 

configFileProvider([configFile(fileId: 'simple-maven-settings', variable: 'MAVEN_USER_SETTINGS')]) { 
    def mavenRuntime = Artifactory.newMavenBuild() 
    mavenRuntime.tool = 'maven350' 
    mavenRuntime.resolver server: artifactory, releaseRepo: '…', snapshotRepo: '…' 
    mavenRuntime.deployer server: artifactory, releaseRepo: '…', snapshotRepo: '…' 

    def buildInfo = mavenRuntime.run pom: 'pom.xml', goals: "-B -s ${MAVEN_USER_SETTINGS} ${goals}".toString() 

これは正常に動作しますが、Mavenは、デフォルトを使用して、場所〜/ .m2 /リポジトリ

共有私が再現したいです私がパイプラインに移動し、各ジョブに独自のローカルリポジトリを与える前に行った動作。

私はそのための任意の設定を見つけることができません... 私はどのように進めるべきか。デフォルトでは

答えて

2

、Mavenは、ユーザのホームの下.m2ディレクトリ内のローカルのMavenリポジトリを使用しています。

def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean install -Dmaven.repo.local=.m2' 

:あなたは、あなたの仕事のワークスペースには、例えば、ローカルリポジトリを作成するために、Mavenを好きここに示すように、目標値に-Dmaven.repo.local = .m2システムプロパティを追加したい場合は -Dmaven.repo.localの値は、このMavenビルドに使用されるローカルMavenリポジトリを指します。 あなたはJenkins Pipeline with Mavenでこのようにそれを行うことができ、それについてhere `

2

をより多くを読むことができます:あり

withMaven(
     // Maven installation declared in the Jenkins "Global Tool Configuration" 
     maven: 'M3', 
     // Maven settings.xml file defined with the Jenkins Config File Provider Plugin 
     // Maven settings and global settings can also be defined in Jenkins Global Tools Configuration 
     mavenSettingsConfig: 'my-maven-settings', 
     mavenLocalRepo: '.repository') { 

     // Run the maven build 
     sh "mvn clean install" 

    } // withMaven 

あなたは、単にローカルキャッシュの場所を定義することができます。

関連する問題