red888
red888

Reputation: 31520

What is the supported way to change version on deploy for Artifactory Maven Jenkins plugin

I'm using the Maven jfrog plugin: https://jenkins.io/doc/pipeline/steps/artifactory/#rtmavendeployer-set-maven-deployer

I want to change the version of the artifact on deploy so it has the feature branch name in it.

I tried to run the set version goal. It succeeds but just totally ignores the version

rtMavenRun (
        pom: "pom.xml",
        goals: 'versions:set -DnewVersion=1.2.3-SNAPSHOT clean install',
        resolverId: 'resolver-unique-id',
        deployerId: 'deployer-unique-id'
)

Upvotes: 0

Views: 714

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35785

The problem is the following: You call the goal versions:set and the phases clean and install in one Maven run. Before the first goal runs, Maven has already resolved the version for all goals/phases that are run. Therefore, you change the version in the POM, but as Maven has already read it, you will not be able to see it during this run.

What are possible solutions?

  • You can run versions:set first and then clean install in a separate Maven run.
  • You can use the property ${revision} in the definition of <version> and then set this property on the command line.

Upvotes: 1

Related Questions