On a migration from gitlab to azure, we need to specify triggers. I have a pipeline on my main (azure-pipelines.yml) which describes the pipeline, I have a trigger condition
trigger:
- none
pr:
branches:
include:
- main
This is purely to make sure that after the merge to main has happened, the pipeline is triggered.
However, if I create any feature to this repo, I create a new branch ( featureX) from master and it will have the same azure-pipelines.yml file. On this branch, I would like the SW to be built for every commit I do to that branch ( featureX). So it makes sense to have the trigger in the branch ( featureX) as follows:
trigger:
branches:
include:
- '*'
Now when the merge is ready, is it a best practise to delete the pipeline file from the featureBranch or do we change the trigger in the yml file of featureBranch?
Or is it handled in a way which I did not mention here?
So you want to trigger a build for every PR and for any feature branches?
If I understand that correctly, keep a single azure-pipelines.yml file and just add a branch trigger:
trigger:
branches:
include:
- feature/*
pr:
branches:
include:
- main
Related
trigger:
branches:
include:
- master
tags:
include:
- Showcase
pr:
branches:
include:
- master
the code above is from my yaml azure pipeline with using bitbucket repo. Anytime I do a PR in my bitbucket repository I expect build pipeline to run automatically in azure devops but it's not the case. Currently, I have to run the pipeline manually to complete PR validation. creating pipeline with the same line of code under another repo works correctly. I'm not sure what the problem is.
I created anoter dummy pipeline with a new project, the pr triggered build automatically when pr to the the master. the webhohook seems to be working fine. the trigger option doesn't override the yaml pipeline. I can't think of anything else to check.
I have my repos hosted on GitHub and running the pipeline on Azure DevOps, it is an iOS pipeline and I am not getting any error but while I try to raise a PR GitHub always gives a warning that I have conflicts and I have to make changes in the main branch as well, which I don't want to do since it might break the workflow is there any work-around for raising the pr without getting the conflict warning?
This is my YAML file:
pool:
vmImage: macOS-latest
trigger:
batch: true
branches:
include:
- develop
- epic/*
# trigger on PR builds targeting any branches
pr:
autoCancel: true
branches:
include: ['*']
# Adding parameters to Run UI
parameters:
- name: FIID
displayName: FIID
type: string
default: 00516
values:
- 00516
- 00031
This is the kind of conflict I am getting, I don't know what I might be doing wrong but I don't want to make changes in the develop branch everytime I have to raise a PR for xcodepipeline
If anyone could help me out that would be much appreciated, thanks.
Merge develop into your feature branch, fix the conflicts, push the changes. The PR should work like a charm after that.
This link should be useful https://akshayranganath.github.io/Git-Pull-Handling-Merge-Conflict/
We want to adopt Trunk Based Development branching policy as explained here.
As a part of our solution we want to trigger Azure pipeline whenever a new release branch is created from master (trunk): for example releases/R.1
Our current yaml for said pipeline looks like this:
trigger:
branches:
include:
- releases/*
...
Unfortunately it doesn't trigger when branch is created. I suspect it will trigger when we make changes to release branch, but according to Trunk Based Development we plan to only merge cherry-picked bugfixes/hotfixes from master. Is there a way to trigger pipeline on branch creation?
Refer to this doc: Behavior of triggers when new branches are created
Here is the behavior when you push a new branch (that matches the branch filters) >to your repository:
If your pipeline has path filters, it will be triggered only if the new branch has >changes to files that match that path filter.
If your pipeline does not have path filters, it will be triggered even if there are >no changes in the new branch.
To trigger the pipeline when a new branch created, you need to remove the path filter and only set branch filter.
For example:
trigger:
- release/*
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
I have a single project but with two "master" branches.
master
virt/master
Each of them would have their own azure-pipeline.yml specific for their branch.
The first pipeline in master has the trigger set up as
trigger:
batch: true
branches:
include:
- refs/heads/master
The second one is in the virt/master branch.
trigger:
batch: true
branches:
include:
- refs/heads/virt/master
Here's the repository that I am experimenting on https://dev.azure.com/trajano/experiments/_git/multi-branch
master build https://dev.azure.com/trajano/experiments/_build?definitionId=11
virt/master build https://dev.azure.com/trajano/experiments/_build?definitionId=12
The problem I am having is when I push a change to the virt/master branch both pipelines get executed
Am I missing something in my configuration? Or is this a bug on Azure Devops?
I also tried to exclude but to no avail.
trigger:
batch: true
branches:
include:
- refs/heads/master
exclude:
- refs/heads/virt/master
If you want to have separate pipelines please create separate file definition for them. I think that your configuration is fine and the issue is that you share the same file as definition.
When I moved to separate file it works as expected:
To create different pipelines for different branches. You need to rename the azure-pipelines.yml file in virt/master branch or create a new yml file with the some contents and with a different name. And create pipeline multi-branch(virt) from this new yml file.
If both pipelines are created from the yaml file with the same name azure-pipeline.yml. And the azure-pipeline.yml file exists in both of the branches. Then they are identical pipelines(even though the azure-pipeline.yml file contents might be different).
You can see from above screen. Pipeline multi-branch and multi-branch(virt) were building the same virt/master branch(using the tasks in the azure-pipeline.yml of virt/master). If you push to master branch. You will see both pipelines will be triggered to build master branch(using the tasks in the azure-pipeline.yml of master). Pipeline multi-branch and multi-branch(virt) are one pipeline
See this thread for more information.
I'd like to push the build status automatically from Azure Devops to the github repository, so that pull requests can check for a build success before they can be merged.
I realise this can be done writing some custom code and calling the github status api, but there is a checkbox for it in the edit pipeline stage. It doesn't seem to work with Github though. See this image .
Other build tools like Bamboo have an out of the box plugin for doing this.
You need to define branch policy. You can read about this on my blog. You need to selected existing pipeline here in GitHub settings:
and then when you make PR you will get this:
You need to correctly define trigger options in your yaml file. For isntance:
this will run for all non master branch (with each commit pushed to GitHub pipeline will run)
for each merge to master will trigger pipeline too
trigger:
branches:
include:
- '*'
exclude:
- master
pr:
branches:
include:
- master
paths:
include:
- gated-checkin/*
exclude:
- gated-checkin/azure-pipelines.yml