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

This widget could not be displayed.
${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


This widget could not be displayed.
Timothy Chin Community Champion Jun 30, 2014

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

This widget could not be displayed.

Thanks a lot!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

154 views 1 3
Join discussion

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