Can I set a custom reason when triggering a build via the REST API?
Asked by Jeffrey Mendez:

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?


Answers:
author: Shashank Kumar
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/270672i5956974D83BE47E3/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/270676i69F969C4C6666308/image-size/large?v=v2&px=999 "image.png")

After the update is run

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270694i484577DFF1ABEAD3/image-size/large?v=v2&px=999 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270695i9CAB7982C1B7F1F2/image-size/large?v=v2&px=999 "image.png")

**Solution 2 :**

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

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270696iCB3AB0E5D89329CB/image-size/large?v=v2&px=999 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270700i3993038F1E6C19FF/image-size/large?v=v2&px=999 "image.png")

You'll be able to see this under Variables tab

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270701iD78AB6629BB9884F/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/270702i01E9E30E40E6C7A3/image-size/large?v=v2&px=999 "image.png")

Let me know if this helps

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

Regards,

Shashank kumar

comments: author: Jeffrey Mendez
body: 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?


author: Shashank Kumar
body: Hello [@Jeffrey Mendez](/t5/user/viewprofilepage/user-id/5233643)

As per the GET Rest API which I used
> [http://localhost:8085/rest/api/latest/result/SCRIP-TIC-91?expand=results.result\&buildstate=successful](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](https://community.atlassian.com/t5/image/serverpage/image-id/271468iD4206ACF114B1C28/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/271473i0183C2AD67F94C3A/image-size/large?v=v2&px=999 "image.png")

Regards,

Shashank Kumar


Tags: rest-api