Extracting maven pom version for release builds

Hi,

Just upgrading to TC 5.0.3 and starting to upgrade our build configurations.

In our environment, we use specific build configurations for releasing maven projects using the maven release plugin.

Earlier, we have been using the mvn-buildnumber-plugin submitted by Mikael Vessgård in relation to http://jetbrains.net/jira/browse/TW-716?disableRedirect&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel
It has been serving us well extracting the maven version from the pom.

As of TC 5.0, I understand that we instead can use %maven.project.version% property which holds the version extracted from the project pom-file (which works fine by the way).

However, I lack the possibility to extract the release-version, ie without the "-SNAPSHOT" part.

Is there currently such a property available? I haven't found any, so I guess not. Is there another way to achieve this that anyone knows about?

Otherwise, may I suggest adding the property %maven.project.version.release% simply holding the same value as %maven.project.version% without the "-SNAPSHOT" part?

Regards, Janne

7 comments

Sure, you may and are welcome to request any feature you lack by submitting an issue at http://youtrack.jetbrains.net/

You guessed right, there is no such a property, and I can hardly suggest any workaround.
So if you feel you really need this, please file an issue with an explanation of your needs.

Thank you.

0

Thanks,

I have created an "issue" , http://youtrack.jetbrains.net/issue/TW-11707

It should be an easy enough task to implement and I can't see that it will affect anything else in a negative way, so my hopes are that you can approve this new feature and have it implemented as soon as possible.

0

Would the TeamCity plugins APIs allow me to parse the build number out of the release's pom.xml (located under <workspace>/target/checkout/target/pom.xml) and expose the property %maven.project.version.release%?  A full solution won't just chop off the -SNAPSHOT but will actually parse the version from this second copy of the pom.xml.

Closest API I can find is: http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/parameters/BuildParametersProvider.html but its not clear from the docs if I can update build parameters from the agent during the build.

0
Hi Brian,
You're on the right way. Besides providing parameter names via implementing BuildParametersProvider, on the agent side you should resolve them by placing their values into the parameter space. See AgentRunningBuild.addSharedConfigParameter(...).
For example:
// server side
public class MyParametersProvider extends AbstractBuildParametersProvider {
  @NotNull
  @Override
  public Collection<String> getParametersAvailableOnAgent(@NotNull final SBuild build) {
    return Arrays.asList("maven.project.version.release");
  }
}
...
// agent side
public class MyReleaseVersionResolver extends AgentLifeCycleAdapter {
  public void buildStarted(@NotNull final AgentRunningBuild runningBuild) {
     String releaseVersion = parseProjectReleaseVersion(); // your method parsing out release version
     runningBuild.addSharedConfigParameter("maven.project.version.release", releaseVersion);
  }
}
0

Thanks so much Sergey. I'll give that a try.

0

Actually I took another route to solve my problem as described here: http://devnet.jetbrains.net/message/5306493#5306493

0

If you only need to set build number that's indeed an easier way

0

Please sign in to leave a comment.