考虑到您需要动态控制目标存储库以进行部署,您有多种选择:
1) 使用 Artifactory Jenkins 插件的管道支持。管道 DSL 允许您动态控制用于Maven解析/部署的存储库,例如:
def rtMaven = Artifactory.newMavenBuild()
rtMaven.resolver server: server, releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot'
rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local'
并添加属性:
rtMaven.deployer.addProperty("status", "in-qa").addProperty("compatibility", "1", "2", "3")
2) 使用Artifactory Maven 插件,它允许您从 pom.xml 定义分辨率/部署和属性。您还可以利用环境变量或系统属性以动态方式定义它们。例如:
<build>
<plugins>
...
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<deployProperties>
<build.name>{{BUILD_NAME}}</build.name>
</deployProperties>
<publisher>
<contextUrl>https://artifactory.mycompany.com</contextUrl>
<username>deployer</username>
<password>******</password>
<repoKey>{{RELEASE_REPO}}</repoKey>
<snapshotRepoKey>{{SNAPSHOT_REPO}}</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
3)正如@viniciusartur 已经回答的那样,您可以使用存储库 URL 中的矩阵参数来定义属性