You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jochen Wiedmann <jo...@gmail.com> on 2018/11/22 11:13:52 UTC
Applying Jenkins build number
Hi,
when running Maven outside of Jenkins, I have the version number (for
example) 1.2, which is just fine. However, within Jenkins I'd like
that to be 1.2.${build.number}. Is that possible without overwriting
the version number in the pom with every build? For example, by using
a "jenkins" profile, which overwrites the project version somehow?
Thanks,
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Applying Jenkins build number
Posted by Matthieu BROUILLARD <ma...@brouillard.fr>.
Fine that you found your way.
The only issue with the technics relying on injection of some external
value is that they make your build not reproducible.
It might not be an issue if those injections are only for intermediate
builds and that you tag your build at some point in time with real X.Y.Z
version.
By jgitver and purely the git information (tags, commits, branches) your
intermediate buillds can be reproducible even later if you checkout later
on.
On Fri, Nov 23, 2018 at 10:08 PM Jochen Wiedmann <jo...@gmail.com>
wrote:
> I believe I came up with a simple solution: My POM now looks like
>
> <groupId>my.group.id</groupId>
> <version>${revision}</version>
> <artifactId>my-artifact-id</artifactId>
> <properties>
> <build.number></build.number>
> <revision>1.2${build.number}</revision>
> </properties>
>
> So, ${build.number} is empty by default, unless in Jenkins, where I
> define it as ".${env.BUILD_NUMBER}".
>
> Jochen
>
> On Thu, Nov 22, 2018 at 12:19 PM Anders Hammar <an...@hammar.net> wrote:
> >
> > Why not just update the pom (but not commit to scm) with a step like
> > mvn versions:set -DnewVersion=$newVersion
> > ?
> >
> > And newVersion you would parse from the pom file and add ${build.number}
> to
> > it.
> >
> > /Anders
> >
> > On Thu, Nov 22, 2018 at 12:14 PM Jochen Wiedmann <
> jochen.wiedmann@gmail.com>
> > wrote:
> >
> > > Hi,
> > >
> > > when running Maven outside of Jenkins, I have the version number (for
> > > example) 1.2, which is just fine. However, within Jenkins I'd like
> > > that to be 1.2.${build.number}. Is that possible without overwriting
> > > the version number in the pom with every build? For example, by using
> > > a "jenkins" profile, which overwrites the project version somehow?
> > >
> > > Thanks,
> > >
> > > Jochen
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Applying Jenkins build number
Posted by Jochen Wiedmann <jo...@gmail.com>.
I believe I came up with a simple solution: My POM now looks like
<groupId>my.group.id</groupId>
<version>${revision}</version>
<artifactId>my-artifact-id</artifactId>
<properties>
<build.number></build.number>
<revision>1.2${build.number}</revision>
</properties>
So, ${build.number} is empty by default, unless in Jenkins, where I
define it as ".${env.BUILD_NUMBER}".
Jochen
On Thu, Nov 22, 2018 at 12:19 PM Anders Hammar <an...@hammar.net> wrote:
>
> Why not just update the pom (but not commit to scm) with a step like
> mvn versions:set -DnewVersion=$newVersion
> ?
>
> And newVersion you would parse from the pom file and add ${build.number} to
> it.
>
> /Anders
>
> On Thu, Nov 22, 2018 at 12:14 PM Jochen Wiedmann <jo...@gmail.com>
> wrote:
>
> > Hi,
> >
> > when running Maven outside of Jenkins, I have the version number (for
> > example) 1.2, which is just fine. However, within Jenkins I'd like
> > that to be 1.2.${build.number}. Is that possible without overwriting
> > the version number in the pom with every build? For example, by using
> > a "jenkins" profile, which overwrites the project version somehow?
> >
> > Thanks,
> >
> > Jochen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Applying Jenkins build number
Posted by Anders Hammar <an...@hammar.net>.
Why not just update the pom (but not commit to scm) with a step like
mvn versions:set -DnewVersion=$newVersion
?
And newVersion you would parse from the pom file and add ${build.number} to
it.
/Anders
On Thu, Nov 22, 2018 at 12:14 PM Jochen Wiedmann <jo...@gmail.com>
wrote:
> Hi,
>
> when running Maven outside of Jenkins, I have the version number (for
> example) 1.2, which is just fine. However, within Jenkins I'd like
> that to be 1.2.${build.number}. Is that possible without overwriting
> the version number in the pom with every build? For example, by using
> a "jenkins" profile, which overwrites the project version somehow?
>
> Thanks,
>
> Jochen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
RE: Applying Jenkins build number
Posted by "Thiebaud, Christophe" <ch...@sap.com>.
cool
-----Original Message-----
From: Matthieu BROUILLARD <ma...@brouillard.fr>
Sent: Freitag, 23. November 2018 15:08
To: users@maven.apache.org; info@soebes.de
Subject: Re: Applying Jenkins build number
You can also use jgitver (https://jgitver.github.io/) that was demoed at
Devoxx this year to compute automatically the project version, even for
each commit.
Using a jgitver configuration of
<configuration>
<mavenLike>false</mavenLike>
<autoIncrementPatch>true</autoIncrementPatch>
<useCommitDistance>true</useCommitDistance>
</configuration>
You can get the versions computed for each commit, for example 1.2.0-1,
1.2.0-2, 1.2.0-3
Matthieu
On Fri, Nov 23, 2018 at 6:54 AM Karl Heinz Marbaise <kh...@gmx.de>
wrote:
> Hi,
>
> On 22/11/18 22:24, Francois MAROT wrote:
> > The new way to deal with such situation is described here:
> > https://maven.apache.org/maven-ci-friendly.html
> >
> > <properties>
> > <revision>0-SNAPSHOT</revision>
> > </properties>
> >
> > <version>1.2.${revision}</revision>
> >
> > and let Jenkins run Maven like this mvn deploy
> > -Drevision=${env.BUILD_NUMBER} (or maybe just $BUILD_NUMBER depending on
> the
> > way you run Jenkins)
>
> Please add the configuration for flatten-maven-plugin to your
> configuration as described on the mentioned page...
>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Applying Jenkins build number
Posted by Matthieu BROUILLARD <ma...@brouillard.fr>.
You can also use jgitver (https://jgitver.github.io/) that was demoed at
Devoxx this year to compute automatically the project version, even for
each commit.
Using a jgitver configuration of
<configuration>
<mavenLike>false</mavenLike>
<autoIncrementPatch>true</autoIncrementPatch>
<useCommitDistance>true</useCommitDistance>
</configuration>
You can get the versions computed for each commit, for example 1.2.0-1,
1.2.0-2, 1.2.0-3
Matthieu
On Fri, Nov 23, 2018 at 6:54 AM Karl Heinz Marbaise <kh...@gmx.de>
wrote:
> Hi,
>
> On 22/11/18 22:24, Francois MAROT wrote:
> > The new way to deal with such situation is described here:
> > https://maven.apache.org/maven-ci-friendly.html
> >
> > <properties>
> > <revision>0-SNAPSHOT</revision>
> > </properties>
> >
> > <version>1.2.${revision}</revision>
> >
> > and let Jenkins run Maven like this mvn deploy
> > -Drevision=${env.BUILD_NUMBER} (or maybe just $BUILD_NUMBER depending on
> the
> > way you run Jenkins)
>
> Please add the configuration for flatten-maven-plugin to your
> configuration as described on the mentioned page...
>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Applying Jenkins build number
Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,
On 22/11/18 22:24, Francois MAROT wrote:
> The new way to deal with such situation is described here:
> https://maven.apache.org/maven-ci-friendly.html
>
> <properties>
> <revision>0-SNAPSHOT</revision>
> </properties>
>
> <version>1.2.${revision}</revision>
>
> and let Jenkins run Maven like this mvn deploy
> -Drevision=${env.BUILD_NUMBER} (or maybe just $BUILD_NUMBER depending on the
> way you run Jenkins)
Please add the configuration for flatten-maven-plugin to your
configuration as described on the mentioned page...
Kind regards
Karl Heinz Marbaise
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Applying Jenkins build number
Posted by Francois MAROT <fr...@gmail.com>.
The new way to deal with such situation is described here:
https://maven.apache.org/maven-ci-friendly.html
<properties>
<revision>0-SNAPSHOT</revision>
</properties>
<version>1.2.${revision}</revision>
and let Jenkins run Maven like this mvn deploy
-Drevision=${env.BUILD_NUMBER} (or maybe just $BUILD_NUMBER depending on the
way you run Jenkins)
--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org