how do I know how my build plan was triggered: manually or automatically (night)?

Hello, I am using Bamboo 5.4.2

How do I know how my build plan was triggered: manually or automatically (night)?

I want to write a script that will react accordingly, depending on whether the build was started manually or automatically (scheduled).

I expect there to be some kind of a variable like ${bamboo.triggered.by}, which sets to "manually", "scheduled", "child".

Please advise.

3 answers

1 accepted

1 vote
Accepted answer
${bamboo.ManualBuildTriggerReason.userName}

It's only populated on manual builds but can be used as a flag in a script or something.

https://confluence.atlassian.com/display/BAMBOO/Bamboo+variables


All right, if it's not a variable, then how can I know if the build was triggered manually?

Hello,

Thank you for your question.

You could use the follwing REST API call:

# URI result/PROJECTKEY-PLANKEY
# (where PROJECTKEY-PLANKEY is the key of the desired build plan of a project, e.g. MYPROJ1-MYPLAN1)

http://<bamboo-baseURL>/rest/api/latest/result/MYPROJ1-MYPLAN1?expand=results.result.buildReason

Please, refer to Bamboo REST Resources for further information.

In the XML response, please search for the <buildReason/> tag. You might find the follwing:

&lt;!-- Initial build --&gt;
&lt;buildReason&gt;First build for this plan&lt;/buildReason&gt;
&lt;!-- Manual build --&gt;
&lt;buildReason&gt;
Manual run by &lt;a href="http://BAMBOO-BASEURL/browse/user/admin"&gt;Administrator&lt;/a&gt;
&lt;/buildReason&gt;
&lt;!-- WebHooks --&gt;
&lt;buildReason&gt;
Changes by &lt;a href="http://BAMBOO-BASEURL/browse/user/admin"&gt;Administrator&lt;/a&gt;
&lt;/buildReason&gt;
&lt;!-- Scheduled --&gt;
&lt;buildReason&gt;Scheduled&lt;/buildReason&gt;
&lt;!-- Dependency (Child of) --&gt;
&lt;buildReason&gt;
Child of &lt;a href="http://BAMBOO-BASEURL/browse/PROJECTKEY-PLANKEY-BUILDNUMBER"&gt;PROJECTKEY-PLANKEY-BUILDNUMBER&lt;/a&gt;
&lt;/buildReason&gt;

Kind regards,
Rafael

Thanks a lot!

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

2,861 views 8 7
View question

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you