In Azure DevOps its possible to define build pipelines which by default is executed when a code is pushed to a branch.
I want the pipeline to run for all branches except one. The configuration
trigger:
branches:
include:
- branchToInclude
exclude:
- branchToExclude
works when I push to branchToInclude.
But if I take away the include part the pipeline is not executed when I push to branchToInclude.
trigger:
branches:
exclude:
- branchToExclude
A * instead of branchToInclude is not accepted when I try to save the file. Is there a way to configure a pipeline to execute for all branches except one?
I suppose something like this should work
trigger:
branches:
include:
- '*'
exclude:
- branchToExclude
Related
I need to trigger the pipeline(CI) when any change is made (directly to the branch or by merging a PR) to my_branch, my yml trigger configuration is like this -
trigger:
batch: true
branches:
include:
- my_branch
paths:
include:
- path/of/the/directory
This works fine if a work item is attached with a PR and the PR is merged with the my_branch.
But, when there is no work item attached to a PR - CI is not triggering after merging the PR.
Am I missing anything?
I tried to reproduce the same in my environment and got the results successfully like below:
Step 1: Created a sample repository. (No branch policies are applied at this stage)
Step 2: Create a basic yaml build pipeline as below.
trigger:
branches:
batch: true
include:
- main
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Sample script'
Step 3: Create a new branch from the main branch.
Step 4: Modify or add some code to the newly created branch and create a Pull Request to the main branch and verify build pipeline.
Note: As I did not set any pull request policies on the main branch, the build pipeline will get triggered only after the feature branch merged to the main branch.
I have a gitlab repo which has two folders(folder-a and folder-b) in it, I want them to get triggered based on the commit on their folder. Currently I have a single gitlab.yml file which has below configuration. It triggers folder-a but not folder-b.
folder-a:
trigger:
include:
- local: folder-a/.gitlab-ci.yml
rules:
- changes: [folder-a/*]
folder-b:
trigger:
include:
- local: folder-b/.gitlab-ci.yml
rules:
- changes: [folder-b/*]
Sorry I had the issue with folder-b .gitlab-ci yml file. this works fine, now able to trigger folder based on commits to the branches
We need to support such piplines in gitlab:
when changes are commit in /sdk/, sdk-pipline will run;
when other changes commit except for /sdk/, main-pipline will run;
SDK pipline script is written as below:
run_sdk_build_pipeline:
stage: trigger
trigger:
strategy: depend
include: "$CI_PROJECT_DIR/.gitlab-ci/pipelines/sdk.gitlab-ci.yml"
rules:
- changes:
- sdk/**/*
Main pipline script is written as below:
run_main_pipeline:
stage: trigger
trigger:
strategy: depend
include: "$CI_PROJECT_DIR/.gitlab-ci/pipelines/main.gitlab-ci.yml"
rules:
- changes:
- // want to trigger it when changes commit except for /sdk/*
How to write this rule condition?
Expect to get help!
In your case, only:changes / except:changes examples may help
run_sdk_build_pipeline:
stage: trigger
trigger:
strategy: depend
include: "$CI_PROJECT_DIR/.gitlab-ci/pipelines/sdk.gitlab-ci.yml"
except:
changes:
- sdk/**/*
I am creating a new CI pipeline that will be triggered anytime a .bicep file is changed and then zip up all of the files.
# Pipeline is triggered anytime there is a change to .bicep files
trigger:
branches:
include:
- "feature/*"
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
This pipeline works and is triggered anytime a change is made in the feature branch.
To target any .bicep files I am trying:
trigger:
branches:
include:
- "feature/*"
paths:
include:
- '**/*.bicep'
I also tried to specify the entire route that holds the files:
trigger:
branches:
include:
- "feature/*"
paths:
include:
- "src/Deployment/IaC/Bicep/*"
When I make a change to a .bicep file in the feature branch, the pipeline is never triggered so I know my syntax is wrong.
Wildcards are not supported anymore for azure pipelines.
Instead just set the relative path to your Bicep folder like so :
paths:
include:
- src/Deployment/IaC/Bicep
see : https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?tabs=yaml&view=azure-devops#paths
I've recently set up an Azure pipeline using the following azure-pipelines.yml file in the master branch:
trigger:
- master
- feature/*
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
I've also tried these two syntax examples for the trigger to no avail as well as removing the trigger completely.
trigger:
branches:
include:
- master
- feature/*
trigger:
branches:
include: ['*']
I've linked this to a GitHub repo where I created a branch called feature/cool_feature.
According to all of the docs I've read, I should be able to place the YAML file in the master branch which should start a build for both my branches. But all I can get this to do is start a build when a commit is made in the master branch.
The only want I could get the build to trigger is if I put another azure-pipelines.yml file inside of that branch.
Is this no longer the case or am I doing something wrong?
Apparently, you must have another copy of the master's azure-pipelines.yml file in the branch for this to work.