admin管理员组

文章数量:1122846

I'm new to working with DevOps pipelines and could use some help. First off, I am working with database code and not application code. Not sure if that makes a difference when it comes to best practices or not.

In my repo I have a dev branch and a main branch. When I merge code into the dev branch I want the pipeline to deploy my code to my dev environment. Then when I merge code to the main branch I want it to deploy to my prod environment. The code I want to deploy is also in a subfolder in those branches, so I only want the pipeline to run when a merge takes place in a specific sub folder.

I currently only have 1 pipeline defined, and it looks like it defaults to pointing to the pipelines.yml file in the main branch.

Here are some snippets from my current pipelines.yml file.

trigger:
  batch: true
  branches:
    include:
    - dev
    - main
  paths:
    exclude:
      - README.md
      - LICENSE
      - .github
    include:
      - dev/.bundle/*      # Path in dev branch to trigger dev stage
      - main/.bundle/*     # Path in main branch to trigger main stage

stages:

- stage: toDev
  variables:
    - group: Dev
  condition: |
    eq(variables['Build.SourceBranch'], 'refs/heads/dev')

..........
..........
..........


- stage: toProd
  variables:
    - group: Prod
  condition: |
    eq(variables['Build.SourceBranch'], 'refs/heads/main')

When I merge a new test file to the dev.bundle folder the pipeline does not do anything, so I must be missing something here. Any help is appreciated.

I'm new to working with DevOps pipelines and could use some help. First off, I am working with database code and not application code. Not sure if that makes a difference when it comes to best practices or not.

In my repo I have a dev branch and a main branch. When I merge code into the dev branch I want the pipeline to deploy my code to my dev environment. Then when I merge code to the main branch I want it to deploy to my prod environment. The code I want to deploy is also in a subfolder in those branches, so I only want the pipeline to run when a merge takes place in a specific sub folder.

I currently only have 1 pipeline defined, and it looks like it defaults to pointing to the pipelines.yml file in the main branch.

Here are some snippets from my current pipelines.yml file.

trigger:
  batch: true
  branches:
    include:
    - dev
    - main
  paths:
    exclude:
      - README.md
      - LICENSE
      - .github
    include:
      - dev/.bundle/*      # Path in dev branch to trigger dev stage
      - main/.bundle/*     # Path in main branch to trigger main stage

stages:

- stage: toDev
  variables:
    - group: Dev
  condition: |
    eq(variables['Build.SourceBranch'], 'refs/heads/dev')

..........
..........
..........


- stage: toProd
  variables:
    - group: Prod
  condition: |
    eq(variables['Build.SourceBranch'], 'refs/heads/main')

When I merge a new test file to the dev.bundle folder the pipeline does not do anything, so I must be missing something here. Any help is appreciated.

Share Improve this question edited Nov 22, 2024 at 22:14 Rui Jarimba 17.4k11 gold badges64 silver badges97 bronze badges asked Nov 22, 2024 at 21:15 AMNAMN 495 bronze badges 2
  • What happens if you remove batch: true? – Rui Jarimba Commented Nov 22, 2024 at 22:15
  • In my pipeline all my "paths" in my "triggers" are wrapped in single quotes. Worth a try. Does the pipeline run if you remove the paths requirement? – Kevin Commented Nov 22, 2024 at 22:25
Add a comment  | 

2 Answers 2

Reset to default 0

I tested the same yaml in my pipeline, it will be triggered when I changed or merged a file to the dev/.bundle or main/.bundle folder.

Please check the steps to troubleshoot your failing triggers:

  1. Check if your YAML CI trigger is overridden by pipeline settings in the UI. You can edit your pipeline, choose ... and then Triggers.

    Check if the Override the YAML trigger from here setting is turned on.

  2. Check if your pipeline paused or disabled. Open the editor for the pipeline, and then select Settings to check. If your pipeline is paused or disabled, then triggers do not work.

  3. For more steps to troubleshoot your failing triggers, please refer this Q&A: I just created a new YAML pipeline with CI/PR triggers, but the pipeline isn't being triggered.

I figured out what my issue was. In the include paths I had the branch name again where I only needed the path. It's working now.

本文标签: Azure DevOps pipeline deploying to multiple environmentsStack Overflow