Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properties lost during Maven release:perform

I'm running maven builds from TeamCity and making use of build.vcs.number to write the Subversion revision into my manifest. In any Maven build with Subversion as the VCS, TeamCity adds

-Dbuild.vcs.number=1234

to the maven command line, where 1234 is the latest revision in the branch being built.

Then in my pom.xml, I have

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
            <manifestEntries>
                <build>${build.vcs.number}</build>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

This all works fine until I run Maven release:perform (also from TeamCity), at which point ${build.vcs.number} becomes null, even though I can see in the TeamCity build log that this property was passed in at the command line.

The maven-release-plugin documentation implies that Maven runs a forked process at some point during the perform goal - is this why I have the problem?

Is there a way I can ensure this particular property gets passed through to that forked process?

like image 522
RCross Avatar asked Sep 12 '12 23:09

RCross


People also ask

What does Mvn Release perform do?

release:perform will fork a new Maven instance to build the checked-out project. This new Maven instance will use the same system configuration and Maven profiles used by the one running the release:perform goal.

How does Mvn release rollback execute when Maven release plugin works?

When a release is rolled back, the following release phases are executed by default: All project POMs are reverted back to their pre-release state locally, and also in the SCM if the previous release command was able to successfully make changes in the SCM to the POMs.

What is the release version for Maven?

<version>3.0. 0-M6</version> <configuration>

How does Jenkins release Maven?

Few examples of different project types are Freestyle, Maven, Multi-configuration, Pipeline etc. Select the "Maven Project" amongst those options, configure your project based on your requirement. And then you'll be able to see the perform maven release option to the extreme right of your jenkins dashboard.


1 Answers

-Darguments=-Dbuild.vcs.number=1234

There is a forked process for release to ensure it has a clean reproducible command line, therefore you need to specify what to pass through.

Ideally you configure the release plugin on your Pom to pass the property through, but failing that use the override (unless somebody has disabled the override in your Pom... Them you're stuck until you re-enable it.

Note: pay close attention to quoting if there are multiple properties or properties with spaces in them

like image 197
Stephen Connolly Avatar answered Sep 28 '22 06:09

Stephen Connolly