Azure DevOps Pipeline - wildcard not trigger pipeline - azure

I would like to ask you what is a the reason of not running a pipeline after making a commit from Visual Studio to repository located in Azure DevOps? Has trigger in yaml lower priority from trigger builded inside pipeline where default is set to develop (Yaml -GetSource)?
My current yaml code:
trigger:
branches:
include:
- feature/*
Name of my current branch local/origin:
feature/employer-service
Thanks in advance for all answers.

As you found in the comment, if you want the branch to get CI triggers, you need to make sure that the same azure-pipelines.yml file exists on the branch.
You can switch to each branch on the pipeline page to check whether the azure-pipelines.yml file is included. If it does not exist, you will get the following error.

Thank you for your time, I've found solution:
In order to run pipeline after making commit from repository, you have to add separate yaml file to branch which actually you are pushing.
I had yaml file on develop branch but the necessary was to add a similar yaml file with whole setup to a new branch.

Related

MultiStage Pipeline triggers from more than one branch

I have a pipeline in Azure DevOps that is triggering from more than just the branch I have specified in the yaml file. I am using bitbucket cloud for my repository.
At first I had the trigger set like this:
trigger:
- development
Then I changed it to this:
trigger:
branches:
include:
- development
It is still triggering from 2 other branches besides development. When I look at the branches tab on the pipeline it has development and the other 2 branches it's triggering from. I also don't have any triggers set in the UI.
Any ideas? Thanks.
Have you updated the YAML file in the correct branch? The branch the pipeline definition is derived from?
As a workaround you could try to add the excludes clause in your YAML trigger to ignore those other two branches.
trigger:
branches:
include:
- development
exclude:
- PBI123
- PBI456
A note on the Branches tab, this is a summary of the pipeline runs that have already been executed, it is not a listing of the branches what will be executed by the pipeline.
I hope this helps resolve your issue.
Ok after looking into it some more I believe this solves it:
pr: none
As long as the PR has that in it. It shouldn't trigger.

Trigger Azure DevOps CI using continuous integration

I need assistance on how to trigger a particular CI when we have multiple projects in one branch.
In my case - I have one project, in the project I have one repository, inside the repository I have one branch, inside the branch I have multiple projects (.CSPROJ) and one solution file(.SLN). If there is a change in project A my CI should get trigger only for that particular project. The other CI which is referring to Project B should not get trigger which is in the same branch.
Pleas assist on this request.
Please check the trigger official document:
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml#paths
Such as:
trigger:
paths:
include:
- some/path/1/*
and
trigger:
paths:
include:
- some/path/2/*

GitHub PR Merge does not trigger Azure DevOps Pipeline

I have my repository on GitHub and my CI/CD pipelines on Azure DevOps. What I want to achieve is, that once a PR merges onto the master branch that the pipeline deploys. No PR creation should trigger the pipeline. Unfortunately I can't seem to get the trigger right.
My trigger looks like this:
trigger:
branches:
include:
- master
pr: none
When I push changes onto the master branch, the pipeline gets triggered. But if I do it via GitHub PR, nothing happens. I also tried it with release pipelines but I seem to have the same problem there. Any pointers in the right direction would be much appreciated!
I'd suggest just use trigger for CI
trigger:
branches:
include:
- master
Omit the pr section.
This would then run your pipeline whenever you make a PR to master as well as once you complete the PR.
And now to prevent the pipeline from running whenever you make the PR and only once you complete the PR to master, use a condition on your build stage
- stage: 'Build'
displayName: 'Build my application'
condition: eq(variables['Build.SourceBranchName'], 'master')
jobs:
etc.....
I have figured it out. Something is completely off in my repository. No idea how I managed that, since I thought that should not even be possible.
Anyway, I tried the triggers with an empty repository and it works like a charm.
I had a similar thing with Pull-Requests from Github. In the end i just used the old school "triggers" section and it started working.
Just edit the pipeline and in the "..." drop down selected triggers and then go to the "Pull Request Validation" row and enable it. Lastly pick the target branch.
Note: sometimes is can take a few minutes for DevOps to pick it up.

Using commit triggers to trigger Azure Devops Pipeline in the YAML File

I have a Question about the Pipline trigger in Devops.
My team and I are using Azure Devops to develop a software.
We use a Branch Specific trigger, to start the pipeline only in out Master Branch. The other branches are ignored in the YAML File.
First part of my question is, that we don't know a way how to trigger the Pipeline over a commit message in our Git tool.
For example: "We work in a different branch than the Master branch -->No Pipeline is running. But we want to trigger the pipeline in this Branch for a Specific test just one time. Our way would be to insert a specific command in the commit text to trigger the pipeline."
My second question is, if it's possible to run different stages in different Branches in one YAML file.
Here again an example: " In our different Branch, we just want to run our unit tests every push. In our Master Branch we want to run our unit tests and after that, we want to build our application.
So far, we started the pipeline at every push and build a new image everytime. But we dont want that, because some pushs arent working and we just push it. We want to decide when the pipeline is running and whitch stage is running.
I hope you can understand my problem. For further questions, please comment here.
Thanks
Question 1:
You can consider using tag triggers to do this. Here is an example:
trigger:
branches:
include:
- master
tags:
include:
- test.*
Then the pipeline will be triggered when working on the master branch or the commit tag is test.*.
Question 2:
You can use conditions. Here is an example:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
Add the condition to your stage, and then the stage will be only triggered by the master branch.
Question 3:
So far, we started the pipeline at every push and build a new image everytime. But we dont want that, because some pushes aren't working and we just push it.
You can skip CI for individual commits.
Just include [skip ci] in the commit message or description of the
HEAD commit and Azure Pipelines will skip running CI.
Update 1:
For Question 1, the test.* means a tag which started with test., such as test.1, test.0.1, and so on. You can change the test.* to anything you want.
As for the question your encountered, you can't create a tag called test.* directly because a tag name cannot contain *.
To avoid confusion, you need to create a tag for the commit to trigger the tag CI, rather than writing it directly in the commit text.
The idea
insert a specific command in the commit text to trigger the pipeline.
I don't think is currently supported and tag trigger is an alternative.
Click this document for detailed information about git tag.
Update 2:
Trigger the stage by master branch or 1620-to-PipelineTrigger branch:
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/1620-to-PipelineTrigger'))
You can set only one condition per stage, but you can create more complex conditions using and, or and ().
Click this document to get more detailed information and examples about conditions.

Azure pipeline will not trigger on tags from Github no matter what

In my azure yml trigger I have:
trigger:
branches:
include:
- refs/tags/v*
tags:
include: ['*']
It won't trigger the pipeline on any tag at all, even without the v.
I'm also commiting a small change when testing to make sure that it's not just the YML that's different from the previous deployment.
My code is in an organisation's private github repo and does trigger on branches, but not on tags.
I test with your yaml sample, there is nothing wrong with the code, it can work well.
does trigger on branches, but not on tags.
From this description, I think the issue could be caused by checking the Override the YAML continuous integration trigger from here option in Triggers. If you check this option ,the trigger set in yaml will be overwritten here.
We have since switched to Github Actions just to have everything into one place, wasn't a big fun of the way Azure Pipelines already integrated into Github, non-issue though.
The issue on my side was the way the push was happening from VScode -- it wasn't pushing tags by default, so I ran:
git config --global push.followTags true
And then from vscode I've started using ctrl+shift+p to create tags and push with follow tags from that prompt, so that would be:
In order to create the tag:
And in order to push with the tag:

Resources