Why plan created in bamboo_specs/bamboo.yml is default to read only?
Asked by Vinh Hong:

Hi I'm new to Bamboo and would love to use YAML specs for setting up plan for each of my service application. Currently when my attempt of creating a plan, I'm getting read only plan which no one can use. I've tried using the "plan-permissions:" as part of the plan, it is throwing exception that "plan-permissions" is an unknown property of the plan.

I'm using Bamboo 6.9.2 and plan permission only work when running through Java Specs.

Thanks,

Vinny


Answers:
author: Jens M?hlenhoff
body: Half a day lost because the documentation on

<https://docs.atlassian.com/bamboo-specs-docs/6.9.0/specs.html?yaml#plan-permissions>

did not pointed out to write it in this way.

Side note:

I see a lot of documentation and implemetation and this is by far the worst one

WebSphere in its first version was better than this. Sorry.

comments: author: Daniel Santos
body: Hi [@Jens M?hlenhoff](/t5/user/viewprofilepage/user-id/3504957)

Thank you for the feedback.

Do you mind sharing your ideas on how this document could be improved?  

I recently created a couple of requests to improve this doc, but I'm pretty sure there is more to be done.   

Thank you!


author: Tim Watts
body: [@Daniel Santos](/t5/user/viewprofilepage/user-id/502125) Maybe the bamboo yaml file settings should be mentioned somewhere on this page: <https://confluence.atlassian.com/bamboo/configuring-a-plan-s-permissions-289276858.html> andpossibly mentioned on this page since it is a related topic: <https://confluence.atlassian.com/bamboo/configuring-project-permissions-938840042.html>


author: Daniel Santos
body: Thank you so much [@Tim Watts](/t5/user/viewprofilepage/user-id/3389211)  

I'll raise a request for that to our tech writers!!!


author: Daniel Santos
body: Hi [@Vinh Hong](/t5/user/viewprofilepage/user-id/3396571) ,

Thank you for raising this question.
> Why plan created in bamboo_specs/bamboo.yml is default to read only?

The intention of this design is to be able to control the plan configuration only from the repository side. This allows you to always have a way to restore an old configuration and also assure your code will be built with the correct build configuration.

Regarding the plan permissions, it is a different story. We recently implemented multiple document sections (called documents) in a YAML file. They are better described here:

* <https://docs.atlassian.com/bamboo-specs-docs/6.9.2/specs.html?yaml#formats>

It means that you need a different section to declare the plan permissions and that is why Bamboo was not able to identify the "plan-permissions" property.

This is an example that would work. It has two document parts:

```
version: 2
plan:
  project-key: SPEC
  key: PLAN
  name: My Plan

stages:
  - Stage 1:
      jobs:
        - Job 1

Job 1:
  tasks:
    - script:
        - echo 'Hello from YAML Specs'

---
version: 2

plan: SPEC-PLAN
plan-permissions:
  - users: admin
    groups: bamboo-admin
    roles: logged-in
    permissions: view
```

<br />

You may be asking why we have this implementation. We did it to allow these document parts to be set in a completely different repository with different ownership/permissions.

Assuming the information about the different documents was not clear, I've created the following ticket as an improvement suggestion:

* [\[BAM-20527\] Improve the way we show different document types in YAML reference](https://jira.atlassian.com/browse/BAM-20527#)

I hope that helps you to move forward.

comments: author: Vinh Hong
body: I've attemped above multi-documents in a single yaml file, I'm getting this error.

```
Bamboo YAML import failed: Invalid format of the YAML file: expected a single document in the stream in 'reader', line 1, column 1:    version: 2    ^but found another document in 'reader', line 77, column 1:    ---?
```

Here is my bamboo.yml

```
version: 2
plan:
  project-key: VINNY
  key:PLAN
  name:Test Plan

stages:
  - Default Stage:
      jobs:
        - Build Application

Build Application:
  requirements:
#    - Maven 3
#    - os: centos \d+
    - JDK 1.8

  artifacts:
    - name:Shell Application
      location:target
      pattern:'my_app.sh'
      shared: true

  tasks:
    - clean
    - script: |
         #!/bin/bash
         mkdir target
         my_app=my_app.sh
         cat >target/${my_app} <<EOT
         ls -l
         pwd
         echo "Welcome to my test app"
         echo "======================================="
         env
         EOT
         war=target/testapp.war
         touch ${war}
         echo "Not a war file" > ${war}
         echo "Trigger build run" >> ${war}
         ls -l
         ls -l target/*
         echo "Build Completed"

---
version: 2
plan:SPEC-PLAN
plan-permissions:
  - users:admin
    groups:bamboo-admin
    roles:logged-in
    permissions: view
```

Anyway, I like the concept of YAML Specs as it is simple to use and learn. This allows developers to quickly adopt to the product where a great learning curve is need to navigate the UI.


author: Daniel Santos
body: It might be an issue related to the plan key used for the plan permissions. Try changing

```
plan:SPEC-PLAN
```

to

```
plan:VINNY-PLAN
```

and let me know what happens.

I was able to make it work with this change.


author: Vinh Hong
body: Same error.

It seems it doesn't like multi-documents. Is there specific setting that I need to activate?


author: Vinh Hong
body: Anyway, found a work around by having my *bamboo_specs/bamboo.yml* pull in each of the doc.

```
!include 'planA.yml'
---
!include 'planAPermssions.yml'
```


author: Daniel Santos
body: Hi [@Vinh Hong](/t5/user/viewprofilepage/user-id/3396571)

I'm glad you found a workaround, but as I mentioned I was able to make it work in 6.9.2 with the same code you posted here.

I noticed a strange thing, you have an error in line 77, but the code posted here don't have 77 lines. Maybe the error was in a different part that was omitted?

If you don't want to investigate what caused the error I understand, but that made me curious.

By the way, thank you for sharing your workaround. I learned something new!