0

Steps of a branch pipeline are not executed if the same branch has another matching pipeline. Please check the code, you might get the idea. Do I need to use any condition? I have tried if conditions as well, no luck. Please help on this.

definitions:
  steps:
    - step: &build-test
        name: 'Build and test'
        script:
          - echo "Your build and test goes here..."
    - step: &Lint
          name: 'Lint'
          script:
            - echo "Your linting goes here..."
    - step: &Securityscan
          name: 'Security scan'
          script:
            - echo "Your security scan goes here..."
    - step: &Deploy-step
          name: 'Deploy-step'
          deployment: staging
          script:
            - echo "your deployment"

pipelines:
  branches:
    '{dev,rev}':                 # this runs
      - step: *build-test
      - step: *Lint
    dev:                         # not executing
      - step: *Securityscan
    rev:                         # not executing
      - step: *Deploy-step
        name: "Deploying to prod"
N1ngu
  • 2,862
  • 17
  • 35

2 Answers2

0

The pipelines don't support what you are trying to do. It picks one branch definition, probably the first one that matches, and run it's steps. Rest of them are ignored, not added on

Randommm
  • 410
  • 1
  • 9
0

As @Randommm explained, and unlike other CI systems you might be more familiar with (e.g. GitLab), only the first pipeline that matches your branch is triggered. If you want to reuse steps in different pipelines, those yaml anchors will be very handful already.

Also, beware of how you override anchors: your syntax for the deployment step is wrong. (Probably you didn't realize because that pipeline was never triggered)

pipelines:
  branches:
    dev:
      - step: *build-test
      - step: *Lint
      - step: *Securityscan
    rev:
      - step: *build-test
      - step: *Lint
      - step:
          <<: *Deploy-step
          name: "Deploying to prod"
          deployment: production
N1ngu
  • 2,862
  • 17
  • 35
  • Thank you for the update @N1ngu. This given answer, when executed it ignores the whole "rev" branch and only executes the "dev". can you help on this to make the both branches to be executed. – vigneshse88 Apr 13 '23 at 08:11
  • Sorry, pipelines should have been under a `branches` definition, answer updated. Does that work for you? Each pipeline should trigger when a new commit is pushed to each branch reference! – N1ngu Apr 13 '23 at 15:49