Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,637
Community Members
 
Community Events
185
Community Groups

Bamboo: how to find if any build agent is running from script

I am relatively new to Bamboo engine. I am writing a script to blow away a cache on each build agent. However, before blowing away cache, I need to check if any build agent is performing any build. If yes, then my script will wait till it finished its job else it will straight away remove cache. Not sure how to check build-agents status from scripts.

Thanks.

2 answers

Hello Rafael,

Thanks for responding. I am aware of the options you have provided in your response. These options will clear cache for all my builds. However, I need to do the clear my cache (or any other directory) only on certain event which I am going to control using a script. 

Please find the snapshot herein to give you a better idea about my implementation. The highlighted line is the place where I need to check if my agent is currently idle or its working.

Just to give you a brief idea about this implementation: I have 10 build agents and on certain events, I need to clear sstate_cache ( other directories) from all the existing build agents. However, I need to make sure I am cleaning build agent only if the build agent is ideal at that time else I will wait till it get ideal.

Screen Shot 2016-12-21 at 2.52.02 PM.png

 

rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 21, 2016

If you are running a build against those 10 Bamboo agents, builds will only run if the the agent is available, otherwise will be sitting on queue. Once their are taken from queue, you could add a Script task to be executed as the first thing in the JOB to delete the caching you are referring to.

You could also run the following REST API call:

curl -k -u BAMBOO_ADMIN -H "Content-type: application/json" -X GET BAMBOO_BASE_URL/rest/api/latest/agent

As a response, you should get:

[{
    "id": 4718593,
    "name": "Agent A",
    "type": "REMOTE",
    "active": false,
    "enabled": true,
    "busy": false
}, {
    "id": 163841,
    "name": "Default Agent",
    "type": "LOCAL",
    "active": true,
    "enabled": true,
    "busy": true
}]

You should be looking at the busy state, if it is true, the agent in question is building something.

I was trying to use this api for very similar semaphoring reasons but to my horror it turns out that it can be out of sync for ~30-60 seconds (we are using Bamboo 6.6.2). I mean I start a build which sleeps for 60 seconds and start to poll 

BAMBOO_BASE_URL/rest/api/latest/agent

And it says for the particular agent "busy": false for ~30 seconds before it starts to report true. 

The same goes after the end of the build. How to ask the bamboo server nicely to report the most recent state? 

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 21, 2016

Hello Ninad,

If possible, could you please provide more information regarding on the cache you are referring to?

Please, find below ways to clean working directory, if this is what you are looking for.

image2016-12-21 20:29:7.png

image2016-12-21 20:31:19.png

Kind regards,

Rafael

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events