[Anthill-pro] Alternate means for retrieving the subversion revision number

Christopher Power chrispower36 at gmail.com
Tue Sep 25 14:46:04 CDT 2007


Thanks Steve, that essentially is what I had already implemented.  Was just
checking to make sure I wasn't missing something.

On 9/25/07, Jeff Adamson <jwa at urbancode.com> wrote:
>
> Chris,
>        Since the stamps on each buildlife is the most recent revision
> included in that buildlife, the fall-back strategy we have typically been
> using for revision based stamping is to parse the stamp from the prior
> build.  The SvnModule (combined with the SvnSourceConfig and SvnRepository)
> is really just a means of describing the layout of the repository used for
> doing checkout/labels/....  It does not readily provide any info relating to
> changelogs or revisions of the current buildlife.
>
>
> A Scripted Stamping Template along the lines of:
> import com.urbancode.vcsdriver3.*;
> import com.urbancode.anthill3.runtime.scripting.helpers.*;
>
> int getMaxChangeSet(ChangeLog[] changelogArray) {
> int result = 0;
> for (int i = 0; i < changelogArray.length; i++) {
>    ChangeSet[] changesetArray = changelogArray[i].getChangeSetArray();
>    for (int j = 0; j < changesetArray.length; j++) {
>      ChangeSet changeset = changesetArray[j];
>      id = changeset.getId();
>      // edit out the "r" character for svn
>      if (id.startsWith("r")) {
>        id = id.substring(1);
>      }
>      int num = (new Integer(id.trim())).intValue();
>      if (num > result) {
>        result = num;
>      }
>    }
> }
> return result;
> }
>
> int highestChangeset = getMaxChangeSet(ChangeLogHelper.getChangeLogArray
> ());
>
> // If there is no changelog, look up the most recent failed and good build
> // and take the highest number. We assume that the version number will
> // be the first stamp.
> if (highestChangeset == 0) {
> lastSuccess = BuildLifeLookup.mostRecentSuccess();
> lastFailure = BuildLifeLookup.mostRecentFailure();
>
> if (lastSuccess != null) {
>   try {
>     highestChangeset = new Integer(lastSuccess.getLatestStampValue
> ()).intValue();
>   } catch (NumberFormatException e) {
>     // stamp was not recognized
>   }
> }
> if (lastFailure != null) {
>   try {
>     highestChangeset = new Integer(lastFailure.getLatestStampValue
> ()).intValue();
>   } catch (NumberFormatException e) {
>     // stamp was not recognized
>   }
> }
> }
> return ""+highestChangeset;
> //------------
>
> I hope this is helpful,
> Jeff
>
>
> Christopher Power wrote:
> > Steve,
> >
> > I am currently using the ChangeLog's ChangeSet ID as described in the
> > online documentation.  However in some cases (such as forced builds,
> > etc.) there might not be a change log hence the question.
> >
> > I read through the APIs and tried a couple things but it wasn't obvious
> > to me the proper way of going about it.  I tried getting the source
> > config, casting it to an SvnSourceConfig and then getting the
> > SvnModule[] to call getRevision().  Is that the appropriate means?
> >
> > Thanks,
> > Chris
> >
> >
> > On 9/21/07, *Steve Boone* <sbb at urbancode.com <mailto:sbb at urbancode.com>>
> > wrote:
> >
> >     Christopher,
> >
> >     You would have to write a script. If the script finds a revision
> >     number it uses it. If it doesn't, you could have it use the last
> >     stamp or modify the last stamp and apply it.
> >
> >     The API is available through the web UI at /remoting and /scripting
> >
> >     If you have any questions, let us know!
> >
> >     Regards,
> >     Steve Boone
> >
> >     On 9/19/07, *Christopher Power* < chrispower36 at gmail.com
> >     <mailto:chrispower36 at gmail.com>> wrote:
> >
> >         I understand and have implemented the script for stamping a
> >         build with the svn revision number using the ChangeLogHelper.
> >         If, however, I force a build without any changes being made to
> >         the repository, there is no ChangeLogArray and therefore no way
> >         to get at the svn revision number.
> >
> >         Is there some alternate means of retrieving the svn revision in
> >         that case?
> >
> >         Thanks,
> >         Chris
> >
> >         _______________________________________________
> >         Anthill-pro mailing list
> >         Anthill-pro at lists.urbancode.com
> >         <mailto:Anthill-pro at lists.urbancode.com>
> >         http://lists.urbancode.com/mailman/listinfo/anthill-pro
> >         <http://lists.urbancode.com/mailman/listinfo/anthill-pro>
> >
> >
> >
> >     _______________________________________________
> >     Anthill-pro mailing list
> >     Anthill-pro at lists.urbancode.com <mailto:
> Anthill-pro at lists.urbancode.com>
> >     http://lists.urbancode.com/mailman/listinfo/anthill-pro
> >     <http://lists.urbancode.com/mailman/listinfo/anthill-pro>
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Anthill-pro mailing list
> > Anthill-pro at lists.urbancode.com
> > http://lists.urbancode.com/mailman/listinfo/anthill-pro
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/anthill-pro/attachments/20070925/c0f33627/attachment.htm


More information about the Anthill-pro mailing list