Push Build status to GitHub - azure-devops

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

Related

pull request doesn't trigger build pipeline

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.

Azure pipeline trigger on tags and branch

I am getting quiet confused here with Azure DevOps build pipeline and GitHub.
In my GitHub I have the following branches:
Master
Develop
My idea and intent is to have a develop pipeline that triggers on each commit to develop branch and master needs to trigger only and exclusively on tags.
So in develop branch I updated my pipelines as follow:
Development pipeline
trigger:
branches:
include:
- develop
and my master pipeline:
trigger:
batch: true
branches:
include:
- master
tags:
include:
- '*'
paths:
exclude:
- /*
Everything works fine and if I push to develop the pipeline triggers, if I create a tag in master also he pipeline works. The problem is if I create and push a tag on develop branch, automatically my master pipeline start building as well.
I don't understand this bit here. Why creating and pushing (not merging) my tag in develop branch triggers the build in master?
What I am expecting from those pipeline is that any push to development branch should trigger development pipeline, and only tags created IN master triggers master pipeline.
Please if anyone can help me to solve and understand this I will be so grateful.
And please if there is any question don't hesitate to ask.
Thank you once again
From documentation
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#ci-triggers
If you specify tags in combination with branch filters, the trigger
will fire if either the branch filter is satisfied or the tag filter
is satisfied. For example, if a pushed tag satisfies the branch
filter, the pipeline triggers even if the tag is excluded by the tag
filter, because the push satisfied the branch filter.
I suppose the best way to fix it is to have different naming conventions for tags for develop and for master and then update it accordingly in Yaml.
You can also tag your master commits which you want to deploy with 2 tags, for example your current tag "v.123" and new tag "master_to_be_deployed" and then in tags include section set include only for "master_to_be_deployed" instead of "*" wildcard.
You can also try to update branches section in master pipeline with exclude section, I am almost sure it will not work acording to documentation
branches:
include:
- master
exclude:
- develop

Azure DevOps Pull Request checker triggered by changes outside from included path

I have a PR checker triggered when someone creates a pull request in Github. My yml file is on GitHub and the pipeline is on Azure DevOps. So, here is my trigger:
PR check
pr:
branches:
include:
- main
paths:
include:
- src/Web
trigger: none
But, when someone makes changes in other directories that are not included in the path above, let's say in src/API or docs it triggers the pipeline and runs a build check. It's not supposed to be checked as I have another pipeline for it.
Can someone point out where the error is?

Azure DevOps run Pipeline when GitHub is pushed but ignore some certain files

I have a Pipeline on Azure DevOps that runs automatically - the trigger is a push to the master branch of my GitHub repo.
This pipeline will build a Docker image and push it to container registry, restart the app, etc. to update the app with the latest changes.
However, there are some certain files I want this Pipeline to ignore (for example, README.md). Is there any way that I can achieve this?
You can a path filter for your pipeline trigger.
If you are using yaml pipeline. You can set the path filter as below:
trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- README.md
If you are using classic UI pipeline. You can go to the Triggers tab and set the path filter

Azure Pipelines GitHub building branches

We are trying out Azure Pipelines CI with a GitHub project now that it is available in the marketplace. I've noticed that it doesn't seem to build branches besides master. Their documentation states that if a trigger section is specified in azure-pipelines.yml that you can configure it to only build specific branches, but that if trigger is not specified that it should be triggering off of all branches.
When I make changes to other branches besides master they do not trigger a build. Anybody know why, or is this a bug?
How did you set in your azure-pipelines.yml file?
Test with GitHub follow the sample mentioned here : Continuous integration (CI) and everything works as expected.
e.g,:
name: My Cool Build
trigger:
It will trigger the build once changes applied to any branch...
I agree that the examples are not clear. Try this example and it should work to build ALL branches:
trigger:
branches:
include:
- refs/heads/*
Try
trigger:
branches:
include: ['*']
As reported in the comments in the docs here (not the docs themselves obvs)