Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add wait time between concurrent builds

Rajib Dey I'm New Here Aug 04, 2021

Hello there,

I would like to understand if it is possible to add wait time between concurrent builds please.

Basically I have a Bamboo plan with three agents dedicated to the plan and the concurrent build is set to 3.

Let say a build is executing on one agent, the build on the next agent should start after X mins of the first build and likewise the build on three agent should initiate after the X mins of second build.

Let me know if my statement is not clear.

 

Thank you!

1 answer

1 vote

Hello @Rajib Dey,

Welcome to Atlassian Community!

There is no such feature in Bamboo. You can work around that by using a script task that will put a delay on the initial job execution.

You will need a common filesystem mounted on all Bamboo agents. This is mandatory so they can communicate and decide on the job execution order.

The following script needs to run as the first task in a Job. It will check if the control file exists, if so it will ask for a file lock. Make sure your NFS/CIFS/Clustered filesystem implementation allows file locking.

If a lock is granted, then it will proceed with some extra checking that will decide if it needs further sleep for X amount of seconds before exiting, but only if the current control file timestamp is lower than the sleep time.

#!/bin/bash
# time in seconds
wait_time=20
# this file should be in a NFS/CIFS share where all agents can write to
control_file=/tmp/job_control
curr_time=$(date +%s)

if [ ! -f ${control_file} ] ; then
touch ${control_file}
else
control_file_time=$(stat --format=%Y ${control_file})
exec 100>${control_file}.lock
if flock 100; then
sleep_time=$(( $curr_time - $control_file_time ))
if [ $sleep_time -lt ${wait_time} ]; then
sleep $(( ${wait_time} - ${sleep_time} ))
fi
fi
echo "Run at second: $(date +%S.%N)"
touch ${control_file}
fi

This is just an example which you can adapt to your needs. It will work in Linux, in Windows you can use PowerShell to achieve similar behaviour.

 

Regards,

Eduardo Alvarenga
Atlassian Support APAC

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center 8.1 is now available

G’day Bamboo customers, Bamboo DC 8.1 is now available with it the following features and programs: SAML 2.0, OpenID Connect, and Crowd SSO In order to help admins with a simplified user manage...

145 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you