How do I prevent two plans to run in parallel and conflict?

Guillaume Lucazeau August 29, 2012

Hello,

I have 7 plans that look like this:

- Update, compile and deploy Maven test module from SVN repository

- Deploy our application and our tests to a Tomcat 6 installation (the same for all the plans)

- Run tests (Selenium)

I tried to schedule the plans so they don't run at the same time, but without leaing too much time between them because they are pretty long to run, and we can't have them to run for 12 hours. The problem is that sometimes, one of them takes longer, so the next scheduled one seems to start and it seems it creates some issues on the Tomcat installation.

How do I do to tell each plan to wait until nothing else runs? We are using only agent.

Thanks!

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
danielwester
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2012

You could set a custom capability on a single build agent and then require the build to be running on that agent. That way it they would queue up.

If you have multiple agents then you could set up 3 different custom capabilitiies: updateandbuild, deploy, selenium and then break your builds up into 3 different stages & jobs with each one depending on each of the requirement. By doing it that way - you could trigger the builds at the same time and if the compilation is faster one one - then the deploy would occur sooner

Guillaume Lucazeau August 31, 2012

Hi,

thank you for your answer but I am not sure to understand what you're suggesting:

I see the capabilities of an agent but only to define an available JDk or something. What I understand is that you suggest to use them as flag, like "isTomcatInUse: y/n" but I don't know how to change a custome capability from a plan. Could you please provide more details about your solutions?

We are currently using only one agent for all our plans.

Thank you!

Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2012

There is an option on an agent "Add Capability". Use that option to create a Custom Capabily named, for example, "gateTomcat".

Then, in each build plan in the job that does the deployment and test, add the Requirement "gateTomcat" exits. That will force all the build plans to use that specific agent to do the deploy and test, and since you only have the capability defined on one agent, it forces any other build that starts to sit in the queue waiting for the previous build to finish, thus making the agent available again.

I've done exactly this same thing to limit builds to one deploy and test at a time

danielwester
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2012

Documentation on capabilities and requirements are at:

https://confluence.atlassian.com/display/BAMBOO/Configuring+a+new+Custom+Capability

https://confluence.atlassian.com/display/BAMBOO/Configuring+a+job%27s+requirements

If you're only using one agent right now then this might be overkill. Just flatten everything into one Job (using Tasks) and the other plans won't gain access to the agent until the job has completed.

If you're going to use multiple plans then check out the above links.

0 votes
Guillaume Lucazeau October 25, 2012

Thanks for all the answers, as we have many jobs in each plan it was easier to schedule them properly instead of flattening everything in one job. But I learned a lot from this thread and will use the agent capabilities in some other plans. As the ticket as been set to resolved I can also expect to get this configuration in bamboo in a next version and that's great. Thanks again to everyone.

0 votes
James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2012

You might be interested in voting for this feature request to prevent builds from running simulatiously when using a shared resource.

Guillaume Lucazeau August 31, 2012

Hello,

I voted for the feature, it seems such a simple and obvious requirement that I don't really understand why we have to do such tricks :-)

Thanks

0 votes
Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2012

A possible solution:

Use ant in your maven and add conditions like waitfor ( http://ant.apache.org/manual/Tasks/waitfor.html ).

For instance, the first build creates a file and deletes it on exit. The second build waits until that file does not exist

Guillaume Lucazeau August 31, 2012

Hello,

I implemented your solution that sounded perfect but here is the situation now, considering two plans A&B launched at the same time, with both containg the three jobs mentionned in my first posts:

A-1: update/install Maven module, starts and finish

B-1: update/install Maven module, starts and finish

A-2: Deploy modules and starts Tomcat, set the flag, starts and finish

B-2: See the flag is here, then wait...

A-3: Tests execution, never starts...

So I guess I will have to find another one :-)

Thanks tho

Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 2, 2012

It works. I did it.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events