[YAML spec] How to make a 'plan permission' for multiple build plan?
Asked by Valerii:

Hi Team,

I'm trying to configure my build plan with a YAML spec and have a problem with plan permissions.

I have created the file "permission.yml" and Imported it in "bamboo.yml"

"permission.yml" has the following instructions:

    ---version: 2plan: PROJECT-PLANKEYplan-permissions:  - users: [ user1, user2, user3 ]    permissions:
          - view
          - build
    ...

    ---version: 2plan: PROJECT-PLANKEY2plan-permissions:  - users: [ user1, user2, user3 ]    permissions:
          - view
          - build
    ...

And in this case I have an error.

Also, I have tried to add permission in every file with a plan configuration, but it gives the same error

```
22-Feb-2023 05:52:12 Bamboo YAML import failed: Invalid format of the YAML file: expected a single document in the stream
22-Feb-2023 05:52:12 in 'reader', line 2, column 1:
22-Feb-2023 05:52:12 version: 2
22-Feb-2023 05:52:12 ^
22-Feb-2023 05:52:12 but found another document
22-Feb-2023 05:52:12 in 'reader', line 84, column 1:
22-Feb-2023 05:52:12 ---
22-Feb-2023 05:52:12 ^
22-Feb-2023 05:52:12 
22-Feb-2023 05:52:12 
22-Feb-2023 05:52:12 Do you need help? Please visit http://docs.atlassian.com/bamboo/docs-0802/Bamboo+Specs+troubleshooting
```

Could you help me find a solution?


Answers:
author: Andrew Trapani
body: If case anyone comes here, I fixed this by moving all of the plan-permissions section to the main \`bamboo.yml\` file OR putting each of the plan-permissions sections into separate files and including them in the \`bamboo.yml\` file.

```
---
version: 2
plan: PROJECT-PLANKEY2

plan-permissions:
  - users: [ user1, user2, user3 ]
(... and all lines
```

When I created new files and did an \`!include my-new-spec-1.yml\` in the main \`bamboo.yml\`, it complained with the same errors described above.

It complained at the Line of Code above \`version: 2\`.

*** ** * ** ***

The problem was my new spec files included the above plan permissions section at the bottom, but this causes spec compiler errors.

Cut the plan-permissions section from the bottom of the new spec files and past them into the bamboo.yml main file

So then the resolved \`bamboo.yml\` file might look something like this:

```
---
!include 'my-new-spec-1.yml'
---
!include 'my-new-spec-2.yml'
---
version: 2
plan:
key: MNS1
plan-permissions:
- roles:
(... and the rest of the lines just from the plan permissions, 
where my-new-spec-1.yml has a plan key of MNS1)
```

OR, create separate files for each of the plan permissions

```
---
!include 'my-new-spec-1.yml'
---
!include 'my-new-spec-2.yml'
---
!include 'my-new-spec-1-permissions.yml'
(... and so on)
```

Where \`my-new-spec-1-permissions.yml\` contains the plan-permissions:

```
---
version: 2
plan:
key: MNS1
plan-permissions:
- roles:
(... and the rest of the lines just from the plan permissions, 
where my-new-spec-1.yml has a plan key of MNS1)
```


author: Eduardo Alvarenga
body: Hello [@Valerii](/t5/user/viewprofilepage/user-id/4984397)

Just remove the first three dots **(...)** from the initial permissions block and it should work.

```
---
version: 2
plan: PROJECT-PLANKEY

plan-permissions:
  - users: [ user1, user2, user3 ]
    permissions:
      - view
      - build
---
version: 2
plan: PROJECT-PLANKEY2

plan-permissions:
  - users: [ user1, user2, user3 ]
    permissions:
      - view
      - build
...
```

The three dots indicate the "*End of Document*" in standard YAML and that will confuse the parser as it had not really ended at that stage.

Sincerely,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: Dave Attard
body: i am having a similar issue with includes that contain multiple "documents"

[bamboo specs include file with multiple documents (atlassian.com)](https://community.atlassian.com/t5/Bamboo-questions/bamboo-specs-include-file-with-multiple-documents/qaq-p/2279292)

```
23-Feb-2023 17:37:02	Bamboo YAML import failed: Invalid format of the YAML file: expected a single document in the stream23-Feb-2023 17:37:02	 in 'reader', line 2, column 1:23-Feb-2023 17:37:02	    version: 223-Feb-2023 17:37:02	    ^23-Feb-2023 17:37:02	but found another document23-Feb-2023 17:37:02	 in 'reader', line 42, column 1:23-Feb-2023 17:37:02	    ---23-Feb-2023 17:37:02	    ^23-Feb-2023 17:37:02	23-Feb-2023 17:37:02	23-Feb-2023 17:37:02	Do you need help? Please visit http://docs.atlassian.com/bamboo/docs-0902/Bamboo+Specs+troubleshooting23-Feb-2023 17:37:02	
```

bamboo.yml

```
---
!include 'Deployment\ServiceA-Deployment.yml'
```

Deployment\\ServiceA-Deployment.yml

```
---
version: 2
deployment:
  name: My deployment
  source-plan: PLAN-KEY
release-naming:
  next-version-name: release-1.0
  applies-to-branches: true
  auto-increment: true
environments:
  - QA
QA:
  tasks:
    - clean
    - artifact-download:
        destination: /workdir
    - script:
        - echo 'hello world'
        - echo "I?m done"
---
version: 2
deployment:
  name: My deployment

deployment-permissions:
  - users:
      - local-admin
      - remote-admin
    groups:
      - bamboo-remote-users
    permissions:
      - view
      - edit
```


author: Valerii
body: Hi [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410) ,

I have tried to remove "..." (three dots) but it doesn't help. The same error.

comments: author: Eduardo Alvarenga
body: Hello [@Valerii](/t5/user/viewprofilepage/user-id/4984397)

As your issue goes beyond a syntax error, I advise you to open a [Support Ticket](https://support.atlassian.com/contact) with Atlassian.

Please do not expose any private information here as it is a public forum.

Cheers,

Eduardo Alvarenga  
Atlassian Support APAC


Tags: yaml