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

Can I set a custom reason when triggering a build via the REST API?

Jeffrey Mendez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 21, 2023

I have a build plan with a task that triggers another plan via the Bamboo REST API. All of the builds that are triggered by the API have the reason: Manual build by <user>

I would like to be able to set the build reason as Child of <project>-<plan>-<number> like when a build is started as a dependency of another build.

Can I set a custom build reason via the Bamboo REST API?

1 answer

2 votes
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2023

Hello Jeffrey,

Welcome to Atlassian community.

If my understanding is correct, you are looking at the Metadata screen for a buildresult and looking at the parameter ManualBuildTriggerReason.userName as per below and looking to change the values to a custom one. Please correct my understanding if it's correct.

image.png

Solution 1 : 

As far as I know within the REST API this param can't be changed but can be overriden(see solution 2), if some how you can modify the column custom_info_value under buildresultsummary_customdata table, you'll be able to see the modified value in Bamboo GUI.

This will require some update query to be fired to the DB.

image.png

 

After the update is run

image.png

image.png

Solution 2 : 

You can define a custom variable on the plan, see below

image.png

  image.png

You'll be able to see this under Variables tab

image.png

You can also pass the system variables as well like bamboo.variable.ManualBuildTriggerReason.userName and it's values would be overriden

image.png

Let me know if this helps

**please don't forget to Accept the answer if your query was answered**

Regards,

Shashank kumar

Jeffrey Mendez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 26, 2023

I ran the REST API query GET /rest/api/latest/result/{projectKey}-{buildKey}/{buildNumber} to see all of the results of my build. I am interested in modifying buildReason, not ManualBuildTriggerReason.userName.

Is it possible to customize buildReason when calling POST /rest/api/latest/queue/{projectKey}-{buildKey}, or modify its value in a task of the queued plan?

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 27, 2023

Hello @Jeffrey Mendez 

As per the GET Rest API which I used 

http://localhost:8085/rest/api/latest/result/SCRIP-TIC-91?expand=results.result&buildstate=successful

I see you are talking about the below buildReason

image.png

I don't think so you can modify this.

As per https://docs.atlassian.com/atlassian-bamboo/REST/8.2.5/#d2e5921 you can pass variables to the Post Request, even if you try to pass buildReason as a variable Bamboo will just consider it as a new one and add it to the metadata

image.png

Regards,

Shashank Kumar

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events