Running parallel steps on pull-requests
Asked by Claudenir Machado:

Hi guys, I have this part of my pipeline:  

```
# omitted
pipelines:
  pull-requests:
    '**':
      - parallel:  # this point
# omitted
```

Is it possible to run parallel tests on this part? The pipeline is valid but it doesn't work when I run it.

Valid pipeline:

![Screenshot from 2020-09-30 20-15-57.png](/t5/image/serverpage/image-id/112483i493EC7FB3E0A666F/image-size/large?v=v2&px=999 "Screenshot from 2020-09-30 20-15-57.png")

Error to execute:

![Screenshot from 2020-09-30 20-16-52.png](/t5/image/serverpage/image-id/112486iF308DDE6ADE711E5/image-size/large?v=v2&px=999 "Screenshot from 2020-09-30 20-16-52.png")

Thanks in advance.


Answers:
author: ktomk
body: Hi [@Claudenir Machado](/t5/user/viewprofilepage/user-id/4107101) , welcome to the Atlassian Community.

The bitbucket-pipelines.yaml online validation (the online tool in your screenshot) does not always show the whole picture.

In your case the configuration error message is mandatory highlighting the error.

The error is not a big one, the \`name:\` property needs to be indented once more into the \`step:\` property turning it into an actual object (instead being null).

That is meant by the error message that the step section is empty (it actually is).

Same is for \`script:\` in your following YAML. Just indent this all once more what belongs into \`step:\` and it should work.

Verifying / Validating a bitbucket-pipelines.yml file is possible on the command-line as well with the [pipelines utility](https://ktomk.github.io/pipelines/). Taking the YAML from your last comment:

Verify via \`--show\`:

```
$ pipelines --show
PIPELINE ID              STEP     IMAGE NAME
custom/create-release    ERROR    step requires a script
branches/develop         ERROR    step requires a script
branches/master          ERROR    step requires a script
pull-requests/**         ERROR    Parallel step must consist of steps only
```

Validate against schema via \`--validate\`:

```
$ bin/pipelines --validate
[pipelines.branches.develop[0].step] NULL value found, but an object is required
[pipelines.branches.develop[0]] The property step is not defined and the definition does not allow additional properties
[pipelines.branches.develop[0]] Failed to match at least one schema
[pipelines.branches.master[0].step] NULL value found, but an object is required
[pipelines.branches.master[0]] The property step is not defined and the definition does not allow additional properties
[pipelines.branches.master[0]] Failed to match at least one schema
[pipelines.custom.create-release[0]] The property step is not defined and the definition does not allow additional properties
[pipelines.custom.create-release[0].step] NULL value found, but an object is required
[pipelines.custom.create-release[0]] Failed to match at least one schema
[pipelines.pull-requests.**[0]] The property parallel is not defined and the definition does not allow additional properties
[pipelines.pull-requests.**[0].parallel[0].step] NULL value found, but an object is required
[pipelines.pull-requests.**[0].parallel[0]] The property script is not defined and the definition does not allow additional properties
[pipelines.pull-requests.**[0].parallel[1].step] NULL value found, but an object is required
[pipelines.pull-requests.**[0].parallel[1]] The property script is not defined and the definition does not allow additional properties
[pipelines.pull-requests.**[0]] Failed to match at least one schema
pipelines: validate done, with errors

```

No idea if these error message are more helpful though ;), just some more options.

If you're using and editor or IDE to edit the files, check for JSON Schema support, despite the file is YAML, JSON Schemas also apply to it (YAML has a JSON representation). Editors / IDEs normally highlight then the erroneous places more visually so errors are easier to catch.

![Selection_080.png](https://community.atlassian.com/t5/image/serverpage/image-id/112832i37AD5E92E0451511/image-dimensions/400x369?v=v2 "Selection_080.png")

bitbucket-pipelines.yml validation inside IntelliJ based IDE (here Phpstorm), works with JSON schema validation via <https://www.schemastore.org/json/> .

comments: author: Claudenir Machado
body: Thanks [@ktomk](/t5/user/viewprofilepage/user-id/3678912) !  

It works now!

```
image: maven:3.6.3-openjdk-11

definitions:
  steps:
    - step: &something
        name: something
        script:
          - echo "step 1"
pipelines:
  custom:
    create-release:
      - step: *something
  branches:
    develop:
      - step: *something
    release/*:
      - step: *something
    hotfix/*:
      - step: *something
    master:
      - step: *something
  pull-requests:
    '**':
      - parallel:
          - step: *something
          - step: *something
```

Thanks again [@ktomk](/t5/user/viewprofilepage/user-id/3678912) and [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) !


author: Theodora Boudale
body: Hi Claudenir,

Running parallel steps on pull-requests should be possible, it succeeds for me with a yml file like the following:

```
pipelines:
? pull-requests:
? ? '**':
? ? ? - parallel:
? ? ? ? - step:
? ? ? ? ? ? script:
? ? ? ? ? ? ? - echo "Step 1"
? ? ? ? - step: 
? ? ? ? ? ? script:
? ? ? ? ? ? ? - echo "Step 2"
```

Would it be possible for you to post here the whole content of your bitbucket-pipelines.yml file so I can check for any issues and try to reproduce this?

If you don't feel comfortable sharing this publicly, you can open a ticket with Bitbucket Cloud support team via <https://support.atlassian.com/contact/#/> and ask for help with this issue. In "What can we help you with?" field select "Technical issues and bugs", then select Bitbucket Cloud as product.

Kind regards,  
Theodora

comments: author: Claudenir Machado
body: Hi Theodora,

For e.g.:

```
image: maven:3.6.3-openjdk-11

definitions:
  steps:
    - step: &something
      name: something
      script:
        - echo "Step 1"
pipelines:
  custom:
    create-release:
      - step: *something
  branches:
    develop:
      - step: *something
    master:
      - step: *something
  pull-requests:
    '**':
      - parallel:
        - step:
          script:
            - echo "Step 1"
        - step:
          script:
            - echo "Step 2"
```

Thanks in advance,

Claudenir


author: Theodora Boudale
body: Hi Claudenir,

Thank you for your reply and example.

As [@ktomk](/t5/user/viewprofilepage/user-id/3678912) correctly pointed out, this looks to be an issue with indentation.

Everything nested under - step: (like name:, script:) should have 4 spaces of indentation, instead of 2. (The commands under script: should still have 2 spaces)

Extra 2 spaces should be added for name:, script: in the definitions, and also in script: in the pull requests steps.

The reason that the validator doesn't show any errors is due to a bug when the yml files uses anchors:

* <https://jira.atlassian.com/browse/BCLOUD-18299>

Does this work for you with these indentation changes?

Kind regards,  
Theodora


Tags: bitbucket-pipelines

parallel