Chou, David | 22 Jan 19:44
Favicon

SVN Revision number as stamp

For setting up a continuous integration builds workflow I would like to be able to identify my builds by SVN revision numbers to make them more distinguishable than the global Build Life numbers.

 

Is there a way to ‘stamp’ the build with the SVN revision number that the build was checked out as?

 

Or is there another way that’s easier?

 

-- David

 

_______________________________________________
Anthill mailing list
Anthill@...
http://lists.urbancode.com/mailman/listinfo/anthill
Steve Boone | 22 Jan 19:54

Re: SVN Revision number as stamp

David,

This script should work for you.  Set this as a stamp scontect script, and then configure your workflow to refer to this script to determine the stamp.



import com.urbancode.anthill3.domain.singleton.serversettings.* ;
import com.urbancode.anthill3.domain.buildlife.*;
import com.urbancode.anthill3.domain.jobtrace.*;
import com.urbancode.anthill3.domain.jobtrace.buildlife.*;
import com.urbancode.anthill3.runtime.scripting.helpers.* ;
import com.urbancode.commons.xml.DOMUtils;
import com.urbancode.vcsdriver3.*;

private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("ContextScript");

// Great, now let's dig out the SVN or Perforce changeset
int getMaxChangeSet(BuildLife life) {
  int result = 0;

  ChangeLog[] changelogArray = ChangeLogHelper.getChangeLogArray(life);
  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;
}

// If there is no changelog, look up the previous build
// and take the highest number from that (if present, else keep searching).
int highestChangeset = 0;
BuildLife life = BuildLifeLookup.getCurrent ();
while(highestChangeset == 0 && life != null) {
  highestChangeset = getMaxChangeSet(life);
  life = life.getPrevBuildLife();
}

stampContext.put("changeset", ""+highestChangeset);


On 1/22/08, Chou, David <dchou-5pgARqJGfcHQT0dZR+AlfA@public.gmane.org> wrote:

For setting up a continuous integration builds workflow I would like to be able to identify my builds by SVN revision numbers to make them more distinguishable than the global Build Life numbers.

 

Is there a way to 'stamp' the build with the SVN revision number that the build was checked out as?

 

Or is there another way that's easier?

 

-- David

 


_______________________________________________
Anthill mailing list
Anthill-IWHQxnLZ/P3rXihlmxnZCEEOCMrvLtNR@public.gmane.org
http://lists.urbancode.com/mailman/listinfo/anthill


_______________________________________________
Anthill mailing list
Anthill@...
http://lists.urbancode.com/mailman/listinfo/anthill
Eric Minick | 22 Jan 20:52

Re: SVN Revision number as stamp

David,

I think you want to be on the anthill-pro mailing list, rather than the 
anthill mailing list. When configuring a stamp on the workflow, there's 
a sneaky little "Advanced Options" above the text field. Select that and 
then add ${stampContext:changeset} to look it up. So you might have a 
stamp like: Build ${+property:buildNum} r${stampContext:changest}. That 
could end up displaying "Build 1.2.3 r45677"

-- Eric

Chou, David wrote:
>
> For setting up a continuous integration builds workflow I would like 
> to be able to identify my builds by SVN revision numbers to make them 
> more distinguishable than the global Build Life numbers.
>
> Is there a way to ‘stamp’ the build with the SVN revision number that 
> the build was checked out as?
>
> Or is there another way that’s easier?
>
> -- David
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Anthill mailing list
> Anthill@...
> http://lists.urbancode.com/mailman/listinfo/anthill
>   
Marcio Marchini | 28 Jan 20:33

Can the list of files changed be passed as parameter to Ant?

Hi,

During the build, with Ant, I want to run a tool only on the files that 
actually changed since the last build under AnthillOS. Can I get this 
passed in as a variable to Ant? I need a list of files changed so that I 
can operate on them.

Thanks,

marcio
Steve Boone | 28 Jan 21:04

Re: Can the list of files changed be passed as parameter to Ant?

Marcio,

You would need to download the source and change the app - even then I'm not sure how long / when the changelog is in a useful object structure to create that property from.

Your other option might be to get an updated changelog from within your script.

Regards,
Steve Boone

On 1/28/08, Marcio Marchini <marcio-9QBLWScaMd9BDgjK7y7TUQ@public.gmane.org> wrote:
Hi,

During the build, with Ant, I want to run a tool only on the files that
actually changed since the last build under AnthillOS. Can I get this
passed in as a variable to Ant? I need a list of files changed so that I
can operate on them.

Thanks,

marcio
_______________________________________________
Anthill mailing list
Anthill-IWHQxnLZ/P3rXihlmxnZCEEOCMrvLtNR@public.gmane.org
http://lists.urbancode.com/mailman/listinfo/anthill

_______________________________________________
Anthill mailing list
Anthill@...
http://lists.urbancode.com/mailman/listinfo/anthill
Jim Hague | 29 Jan 08:47
X-Face
Picon
Favicon
Gravatar

Re: Can the list of files changed be passed as parameter to Ant?

On Monday 28 Jan 2008, Marcio Marchini wrote:
> During the build, with Ant, I want to run a tool only on the files that
> actually changed since the last build under AnthillOS. Can I get this
> passed in as a variable to Ant? I need a list of files changed so that I
> can operate on them.

Anthill doesn't pass any such information into the build at present. Modifying 
it to pass in the timestamp or changeset identifier of the last successful 
build would be possible.

It would probably be simpler to set the project to tag on successful builds, 
and then in your build script find the most recent Anthill tag and get the 
list of changes since then.
--

-- 
Jim Hague - jim.hague@...          Never trust a computer you can't lift.

Gmane