Can I have a remote trigger only on the plan branches?
Asked by Vivien Jovet:

Hi,

Context:

I have configured a build plan for the branches (so not develop or master), the repository for the plan is pointing to the develop branch, and I setup plan branch management so that only branches on PR have a plan branch, the plan branches have a remote trigger (bitbucket cloud webhook).

Problem:

The plan branches are not triggered by the webhook, the response from Bamboo server is 400 with body "The plan \[xxx - Branches\] is not configured for remote triggering."

If I add a remote trigger to the parent plan itself (in addition of the one for the plan branches) it will trigger a build for the develop branch when there is a commit pushed to it (and there is a separate plan for the develop branch).

Question:

How do I achieve this? Is there a workaround? Is it a bug?

ps: I'm using Bamboo specs to create the plans.


Answers:
author: Daniel Santos
body: Hi [@Vivien Jovet](/t5/user/viewprofilepage/user-id/3210986)

Yes, you need the remote trigger configured in the main plan, but you can disable that one and therefore it will not be triggered.

Please add your **Remote trigger** back and disable the main plan by going to:

* **Plan configuration \>\> Plan details** and uncheck the **\[ \]Plan enabled**checkbox.

I hope that will give you the behavior you want.  
I don't think this is a bug, but the way Bamboo was designed to work.

Please let me know the results you get.

comments: author: Vivien Jovet
body: Thanks for your answer, I will try that today.


author: Vivien Jovet
body: It worked! Do I still need to set the trigger on the plan branches or set it to inherit the main plan trigger?


author: Vivien Jovet
body: Actually it works but it's not practical using Bamboo Specs, if I disable the plan when uploading the spec Bamboo will discard it.

Report from the scan:

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

And the plans generated:

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

You can see it's missing the \`Branches\` plan.

We'd have to remember to disable the main plan manually every time we make changes via Bamboo Specs.


author: Daniel Santos
body: Hi [@Vivien Jovet](/t5/user/viewprofilepage/user-id/3210986)

I've opened a bug for this behavior, it seems incoherent to me and can confuse users:

* [\[BAM-20669\] Setting a plan as disabled prevents specs of publishing its configuration](https://jira.atlassian.com/browse/BAM-20669)

I was thinking about your initial issue and it seems simpler just to publish this plan with a different main repository. Instead of using **develop** branch, is it possible for you to use one of the branches that should be built in this plan?


author: Vivien Jovet
body: No I can't do that unless I leave a dead branch at all time. The \`Branches\` plan I've shown above is meant for feature and bugfix branches, so once they're merged into the develop branch, they are deleted.

Does Bamboo have a REST API endpoint to disable a plan? If it does I could add a behavior to the plan spec class so that if a plan is disabled, it set it enabled before to publish and make a request to disable it afterward. At least until BAM-20669 is resolved.


author: Daniel Santos
body: Hi [@Vivien Jovet](/t5/user/viewprofilepage/user-id/3210986)
> No I can't do that unless I leave a dead branch at all time. The \`Branches\` plan I've shown above is meant for feature and bugfix branches, so once they're merged into the develop branch, they are deleted.

Got it! Thank you for explaining it.
> Does Bamboo have a REST API endpoint to disable a plan? If it does I could add a behavior to the plan spec class so that if a plan is disabled, it set it enabled before to publish and make a request to disable it afterward. At least until BAM-20669 is resolved.

Yes, there is an API endpoint for that.

**Enable a plan**

```
curl -k -u <BAMBOO_ADMIN_USER>:<BAMBOO_PASSWORD> \
? ? ? ?-H "Content-type: application/json" \
? ? ? ?-X POST "<BAMBOO_URL>/rest/api/latest/plan/<FULL_PLAN_KEY>/enable"
```

**Disable a plan**

```
curl -k -u <BAMBOO_ADMIN_USER>:<BAMBOO_PASSWORD> \
? ? ? ? -H "Content-type: application/json" \
? ? ? ? -X DELETE "<BAMBOO_URL>/rest/api/latest/plan/<FULL_PLAN_KEY>/enable"
```

I hope that helps to temporarily solve the issue. =\]


author: Vivien Jovet
body: Those API endpoints work but I'm having trouble using it within the Bamboo Specs scanner which has a security manager preventing my code to work.

I'm getting:

```
Caused by: java.security.AccessControlException: access denied ("java.net.SocketPermission" "bamboo.xxx.com" "resolve")
```

Is there a way to change the settings of the security manager?


author: Daniel Santos
body: Hi [@Vivien Jovet](/t5/user/viewprofilepage/user-id/3210986)

I've contacted the development team got from them that this is a known security implication. It intends to save users from malicious code embedded in specs. Unfortunately, you will not be able to use the rest API that way.  

I guess the best option we have now is to use a dummy branch as the main branch. That will let you this separation of plans that you need.