I have a Jenkins job, that has REPOSITORY and BRANCH input variables and uses Invoke top-level Maven targets plugin. It makes maven clean deploy to jfrog artifactory.
But there is a problem: I don't know, how to send properties to the artifacts, that were deployed. I mean properties like these, that we have in JFROG ARTIFACTORY:
I know, that there is Maven3-Artifactory Integration plugin that makes a deploy with properties, but it doesn't work in my case, because my job should be general for different artifactory servers.
I also found a parameter Properties in Invoke top-level Maven targets but it does nothing (the list of properties of deployed artifacts is still empty)
How can I send properties to JFROG ARTIFACTORY by maven Invoke top-level Maven targets plugin? Thanks in advance.
Taking into consideration you have a requirement to dynamically control the target repository for deployment, you have multiple option:
1) Use the pipeline support of the Artifactory Jenkins plugin. The pipeline DSL allows you to dynamically control the repositories you are using for Maven resolution/deployment, for example:
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'
And add properties:
rtMaven.deployer.addProperty("status", "in-qa").addProperty("compatibility", "1", "2", "3")
2) Use the Artifactory Maven plugin which allows you to define the resolution/deployment and properties from the pom.xml. You can also leverage environment variables or system properties to define those in a dynamic way. For example:
<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) As already answered by @viniciusartur, you can use matrix parameters in the repository URL to define properties