Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Delegating creation of build.version to Ant #4

ollhal ·
Feature request:

I want to construct the build.version property in my Ant script and make it available in the QuickBuild configuration.

Background:

Ant is our reference build system. CI engines like Luntbuild/QuickBuild/CruiseControl/Anthill are just convenience tools.

I want the exact same result no matter if I start Ant manually from the command line or if it is invoked by some CI engine.

Our Ant scripts construct the version string by combining the content of a version.properties file in the root of the project with the result of a custom Ant target that picks up the highest Perforce change number for that particular depot path.

By doing it this way, we have eliminated the need for labeling, since all published artifacts have a name that includes the Perforce changelist number. And as you perhaps know, a Perforce changelist number identifies a snapshot of the repository!

What I would like to have is a mechanism for setting QuickBuild OGNL values from a custom script. Groovy is particularly well suited for this, since it integrates seamlessly with Ant.

Regards,
Olle
  • replies 8
  • views 6337
  • stars 0
robinshen ADMIN ·
Olle,

How about setting build version in QuickBuild as:
${system.readOutput("/path/to/ant -buildfile /path/to/build.xml changelistnumber").trim()}

The "readOutput" method of the "system" class reads output from provided command.

Also for future version, we'll add direct support to get perforce change list number inside QuickBuild (that is, you do not need to read output of an external command).

As for Groovy, we'll make some investigation to see how QuickBuild can benefit from that. Thanks for this information, <!-- s8) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8)" title="Cool" /><!-- s8) -->

Thanks.

[quote="ollhal"]Feature request:

I want to construct the build.version property in my Ant script and make it available in the QuickBuild configuration.

Background:

Ant is our reference build system. CI engines like Luntbuild/QuickBuild/CruiseControl/Anthill are just convenience tools.

I want the exact same result no matter if I start Ant manually from the command line or if it is invoked by some CI engine.

Our Ant scripts construct the version string by combining the content of a version.properties file in the root of the project with the result of a custom Ant target that picks up the highest Perforce change number for that particular depot path.

By doing it this way, we have eliminated the need for labeling, since all published artifacts have a name that includes the Perforce changelist number. And as you perhaps know, a Perforce changelist number identifies a snapshot of the repository!

What I would like to have is a mechanism for setting QuickBuild OGNL values from a custom script. Groovy is particularly well suited for this, since it integrates seamlessly with Ant.

Regards,
Olle[/quote]
ollhal ·
If it works it is good enough for me, so I'll give it a try. Stay tuned...

Olle
ollhal ·
If I'm correctly informed, it is possible to invoke static methods from OGNL by the syntax ${@class@method(args)}

This way, the OGNL expressions could be simplified, moving the complexity
to a custom Java class that we deploy into QuickBuild.
robinshen ADMIN ·
Olle,
This is a good idea. Future version of QuickBuild will define several extension points includes OGNL.
Regards.

[quote="ollhal"]If I'm correctly informed, it is possible to invoke static methods from OGNL by the syntax ${@class@method(args)}

This way, the OGNL expressions could be simplified, moving the complexity
to a custom Java class that we deploy into QuickBuild.[/quote]
dmp1ce ·
Here is another way to get the current P4 revision using OGNL:

${#matcher=System.createMatcher(System.createPattern("[0-9]+"),System.readOutput("p4.exe changes -s submitted -m 1").trim()), #matcher.group()}
robinshen ADMIN ·
Although now it is possible to extract revision number through this way, but the revision actually been checked out may differs from this number. Later on we address this problem to provide an easy way to extract the revision number and make sure QuickBuild checks out the same revision.
hyunji.kim ·
I want to have a version name that includes the Perforce changelist number.

Can I have the ONGL expressions for setting Perforce changelist number for the particular depot path?

Regards,
Hj Kim
robinshen ADMIN ·
Sure, just include below expression as part of your version string:

${repository["perforce"].headRevision}

Here "perforce" is assumed to be name of the Perforce repository you've created at QuickBuild side.

Regards.
Robin