How can I skip default pipeline on pull request?
Asked Answered
I

1

8

In the project I am currently working on, I want to run the bitbucket pipeline according to the following rules.

  • Test and lint steps should run for each commit pushed to Branch.
  • The test-with-coverage and lint steps must be run for each record opened with Pull Request.

The problem here is that if I push a commit to a branch that I have opened a pull request, the pipeline is triggered twice.

pipelines:
  default:
    - step: *lint
    - step: *test
  pull-requests:
    '**':
      - step: *lint
      - step: *test-with-coverage

I looked for a way to skip default pipeline if a pull request exists, but I can't find it. I am open to suggestions and opinions.

Illinois answered 3/12, 2019 at 7:45 Comment(4)
Curious, but why wouldn't you want tests run when a pull request is updated? The PR is only updated if something changes, so you'd be skipping tests on those new commits - and letting potentially bad code through as a result.Abercrombie
I don't want to skip tests on pull request. However, if there is a PR, I want to run different pipeline. In branch, I only run tests. However, if there is PR, I want to run test with minimum code coverage limit (Only if there is a pr). I'll add sonarqube if there is a pipeline as well.Freezer
Did you figure it out maybe? I have exactly the same question :)Trinidadtrinitarian
Unfortunately I couldn't find any way to do this :(Freezer
V
-2
pipelines:
  default:
    - step: *lint
    - step: *test
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: never
  pull-requests:
    '**':
      - step: *lint
      - step: *test-with-coverage



Vincevincelette answered 10/8, 2022 at 21:6 Comment(2)
Where did you find the "rules:" block? I cant find anything about this and it does not work for me in my build. I do see some info about a "conditions" block support.atlassian.com/bitbucket-cloud/docs/… but while that is at least recognized as valid it still does not achieve the desired effect of aboveRosina
I think @artak is referring to gitlab pipelines: docs.gitlab.com/ee/ci/yaml/#rulesMeliorism

© 2022 - 2024 — McMap. All rights reserved.