Staging feature in Bitbucket cloud
Asked by Vysakh M:

Bitbucket has one **stage** feature that allows to have multiple steps inside a single stage and i was trying to find out the correct approach to do this with the **Allowed parent** properties as default, branches, pull-requests, tags, and custom. When i was trying in VS code and it gives me **Code** **Property stage is not allowed** . Can someone give me the correct way of doing this part. Below is the method that i was trying and attached the screenshots for the same   

image: hashicorp/terraform:latest  
pipelines:  
branches:  
'{feature-dev-\*,feature-qa-\*,feature-master-\*}':  
- stage:  
name: Build and test  
steps:  
- step:  
name: Deploy  
script:  
- \|  
branch=$(echo $BITBUCKET_BRANCH \| awk -F'-' '{print tolower($2)}')  

<br />

![property.png](/t5/image/serverpage/image-id/282642iF67C2EEE6E809AF7/image-size/large?v=v2&px=999 "property.png")  


Answers:
author: Theodora Boudale
body: Hi Vysakh and welcome to the community!

The bitbucket-pipelines.yml file you posted here is valid. I tried running a build with this yml and there were no issues.

You can use the following validator to validate your bitbucket-pipelines.yml file:

* <https://bitbucket-pipelines.atlassian.io/validator>

Just a heads up, there is a bug with the validator when yaml anchors are used. In this case, the validator doesn't show any errors.

VS code is not built by Atlassian, so I'm not sure why it shows an error and how exactly it does the validation. If you want to find out, it may be best to reach out to a VS Code-specific forum or the product's support team.

Kind regards,  
Theodora

comments: author: Vysakh M
body: Hi Theodora,

Thanks for your comments regarding this issue. When I introduced the stage feature I got the below error from the pipeline. Please look this one as well

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


author: Theodora Boudale
body: Hi Vysakh,

This error shows when there is an error with indentation.

* Please make sure that you use indentation with spaces (not tabs).
* You need to use at least 1 space for indentation, except for everything listed under **- step:** and **- stage:** which should be at least 3 spaces.

You can try with indentation as follows: (**Edited** to correct the yml indentation)

```
image: hashicorp/terraform:latest
pipelines:
  branches:
    '{feature-dev-*,feature-qa-*,feature-master-*}':
      - stage:
          name: Build and test
          steps:
            - step:
                name: Deploy
                script:
                  - |
                   branch=$(echo $BITBUCKET_BRANCH | awk -F'-' '{print tolower($2)}')
```

Please feel free to let me know how it goes.

Kind regards,  
Theodora


author: Vysakh M
body: Hi Theodora,  
Thanks for your reply and there was a slight change in the code that you shared above. It should be:

```
image: hashicorp/terraform:latest
pipelines:
```

Once more thanks for the correction in the stage section. Now the pipeline is working as I expected.  
Thanks and Regards  
Vysakh M


author: Theodora Boudale
body: Hi Vysakh,

You are absolutely right, I slipped up. I will edit my reply to avoid confusion.

It's good to hear that the pipeline is working now. Please feel free to reach out if you ever need anything else!

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud