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

${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 Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,064 views 0 5
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot