Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Multiple conditions in bitbucket-pipelines.yml

Hrvoje Pavlinovic June 9, 2021

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


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

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.

1 answer

0 votes
Abdul Rehman June 22, 2022

@Patrik S 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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events