Multiple conditions in bitbucket-pipelines.yml
Asked by Hrvoje Pavlinovic:

Hi, I'm having issue with setting up multiple conditions in bitbucket-pipelines.yml.  

When I define only one condition, it works properly, but if I define two conditions, each step is triggered regardless of defined conditions.

Here is simplified example, defining only one condition works as intended:  

![Screenshot from 2021-06-09 13-00-05.png](https://community.atlassian.com/t5/image/serverpage/image-id/146741iE750733EBE6C5C96/image-size/large?v=v2&px=999 "Screenshot from 2021-06-09 13-00-05.png")  

<br />

But if define another condition, then all steps are executed each time:  

![Screenshot from 2021-06-09 13-01-11.png](https://community.atlassian.com/t5/image/serverpage/image-id/146742i095916404565FBCC/image-size/large?v=v2&px=999 "Screenshot from 2021-06-09 13-01-11.png")

I haven't found any similar use case or related documentation on this.  
Does anyone know if this is even possible, and if yes, how it should be implemented?  

Thanks in advance.


Answers:
author: Abdul Rehman
body: [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) Can you please answer this question, I'm also looking for a solution related to this kind of use case.   
In my use case I want to skip/ no skip pipeline if condition becomes true/false. My pipeline is a bit lengthy but I will share some part of it, pipeline is 100% working but it skips the pipeline even if there is a change in the includePaths   

```
image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge

definitions:

  caches:

    npm: $HOME/.npm

    cypress: $HOME/.cache/Cypress

  steps:

    - step: &step-chrome

        name: Testing in Chrome

        caches:

          - npm

          - node

          - cypress

        script:

          #- npx @bahmutov/print-env BITBUCKET

          - npm ci

          - npm run start:ci &

          - npm run e2e:record:chrome -- --parallel --ci-build-id $BITBUCKET_BUILD_NUMBER

        artifacts:

        # store any generates images and videos as artifacts

          - cypress/screenshots/**

          - cypress/videos/**

    - step: &step-firefox

        name: Testing in Firefox

        caches:

          - node

          - cypress

        script:

          - npm ci

          - npm run start:ci &

          - npm run e2e:record:firefox -- --parallel --ci-build-id $BITBUCKET_BUILD_NUMBER

        artifacts:

        # store any generates images and videos as artifacts

          - cypress/screenshots/**

          - cypress/videos/**

    

    - step: &step-edge

        name: Testing in Edge

        caches:

          - node

          - cypress

        script:

          - npm ci

          - npm run start:ci &

          - npm run e2e:record:edge -- --parallel --ci-build-id $BITBUCKET_BUILD_NUMBER

        artifacts:

        # store any generates images and videos as artifacts

          - cypress/screenshots/**

          - cypress/videos/**
```

```
?
```

```
pipelines:
  branches:
    default:
       ...
       ...
       ...

    develop:
       ...
       ...
       ...

    prerelease:
       ...
       ...
       ...

    main:

      - step:

          name: Preparing Dependencies

          caches:

            - npm

            - node

            - cypress

          script:

            - npx @bahmutov/print-env BITBUCKET

            - npm ci

      - parallel:

      ################ 12X-Machines-Chrome #######################

      # To add additional machine simply copy each step and paste

      ###########################################################

        - step:

            name: 1X-Chrome

            # Condition to stop pipeline if there are no changes in code

            condition:

                changesets:

                    includePaths:

                        # Any changes in Cypress Directories

                        - fixtures/**

                        - integration/**

                        - plugins/**

                        - support/**

                        # - "videos/**"

            <<: *step-chrome

            deployment: prod

```

comments: author: Abdul Rehman
body: SOLVED:  
I got my answer here <https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-pipelines-Run-or-skip-step-based-on-Condition-and/qaq-p/2057955#U2062241>


Tags: bitbucket-pipelines

cloud