A late reply, but as this thread appears on Google for trying to solve this 
problem, I figured I'd post my solution. It isn't great as you can't use 
the Git plugin, so a new BuildChooser would be superior, but it does result 
in one build per git commit across all branches.

First, modify your job to echo the last built commit to somewhere in the 
workspace (such as last_built_commit), or preferably throw it in S3 or 
something more persistent.

Now, use the ScriptTrigger plugin and create a script to see if the 
last_built_commit is still the latest, exiting 0 if not. Here's my example:

LAST_BUILT=`cat $WORKSPACE/last_built_commit` # or curl from S3 or wherever
> NEXT_COMMIT=`cd $WORKSPACE/repo && git rev-list --all --remotes --reverse 
> -n 100 | grep -A 1 $LAST_BUILT | tail -n 1`
> echo $NEXT_COMMIT > $WORKSPACE/next_build_commit
> # If the last built commit is not the newest, exit 0, meaning we need a 
> new build.
> [[ $LAST_BUILT != $NEXT_COMMIT ]]


Finally, handle git clone / pulling yourself in a build step: "if [ ! -e 
repo ]; then git clone repo.git; fi; cd repo && git fetch --all && git 
checkout `cat $WORKSPACE/next_build_commit`"

Ta-da! As far as I can tell, this works well, since a Jenkins restart or 
job failure will result in another attempt at that commit. Depending on 
where you write your last_built_commit you can control whether it will 
retry commits or skip failures.

I'd definitely love to see a BuildChooser that handled this, including for 
a branch specifier of **; that would be quite wonderful. However for now I 
figured this solution might help others, or maybe someone will point out a 
better way for me :)

- Mike

On Friday, July 8, 2011 3:24:59 PM UTC-4, Randall R Schulz wrote:
>
> Hi,
>
> I'm using Jenkins to drive automated tests triggered by Git commits. 
> Because of the duration of the tests and the frequency of commits (at 
> certain times of the day), often multiple commits occur while the tests 
> from an earlier commit are running.
>
> I need to perform a full test run for each commit without this "batching" 
> or "clumping" of multiple commits arriving during a test run.
>
> How might I achieve that?
>
>
> Randall Schulz
>

Reply via email to