Azure DevOps: How to avoid a build on new branch creation - azure-devops

In our Azure DevOps Build pipeline, I set "Enable continuous integration" to true, and set a filter to include only feature branches.
This is working fine as expected - a build kicks off every time a user pushes changes from the local to remote feature branch.
The only issue I see is on branch creation - when a user creates a new branch from within their work item in the online DevOps in the Development pane, it triggers a new build as well. The branch is Based on "Development" branch, in pic above.
How can I avoid a build on branch creation, and only have a build when changes are checked in?

How can I avoid a build on branch creation, and only have a build when changes are checked in?
I am afraid we could not achieve this at this moment. That because this is the current Azure Devops default design behavior, all files and paths in this branch are "new", which is also seen as a new change.
You can submit a user voice here:
https://developercommunity.visualstudio.com/content/idea/post.html?space=21
How to avoid a build on new branch creation
The workaround for this issue, you can create the Development branch with following construction Development/Test01:
Then set the Branch filters like Development/*:
Manually add in the textbox that allow you to "Filter my branches" and press Enter button:
Then if you create a new branch based on 'Development/Test01' branch, like 'Development/Test02':
The new created branch will not trigger a new build.
Hope this helps.

Related

How to configure and execute Azure Devops classic editor pipeline after commit in Github?

I have a Github and Azure Devops classic editor pipeline. I want to configure an auto-trigger of Azure pipeline after a commit happened in Github (If any commit happens in the repository, it needs to trigger my Azure Devops pipeline)
I tried configuring Continuous Integration in pipeline level, and it does not trigger my pipeline after a Github commit.
Many documents are for yaml pipeline but we need for classic editor pipeline. Could someone provide your inputs on how can we achieve the same ? Thanks!
You are looking for CI/CD triggers, you can simply choose the proper branch in the build trigger combo box.
"In the classic editor, pipeline triggers are called build completion triggers. You can select any other build in the same project to be the triggering pipeline.
After you add a build completion trigger, select the triggering build. If the triggering build is sourced from a Git repo, you can also specify branch filters. If you want to use wildcard characters, then type the branch specification (for example, features/modules/*) and then press Enter."
Source: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/pipeline-triggers-classic?view=azure-devops
if you are looking for deployment triggers you can find more info here:
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/triggers?view=azure-devops
release trigger snapshot
The configuration of #Bayoudhi Bilel is correct, after you select the Github as resource for Class editor pipeline, enable CI trigger in "Triggers" tab. (official doc here)
Check on my side, it works fine:
If your setting doesn't work, please firstly check if you have select correct branch to monitor. If it's correct, you can follow below steps to reconnect between azure devops and github repo.
Delete all webhooks on github repo setting.
Then edit your pipeline, go to "Triggers" tab, "restore" the webhook.
change to a new service connection(it's recommended to regenerate the github PAT, you can simply add all scope):
In my Azure devops, i did it by going to pipeline > Triggers tab and i activated "Enable continous integration". You can also configure the branches you want to build from.
It worked for me this way.
Please find screenshot attached.

Is there a way to identify the TFS branch that was checked into in an Azure Devops CI build?

I have a TFVC project with about 4 branches. I need to somehow setup build and release pipelines that build an artifact for each branch. Because I will eventually need to repeat this process elsewhere, I would like to prevent having to duplicate the same build pipelines for each branch. I am able to configure a single build pipeline that works on whatever branch I need using a user-defined variable when the pipeline is kicked off, but now I need to enable continuous integration on the build.
My current build pipeline trigger configuration
I need this to work such that whenever someone checks into one of the TFVC branches, the build is kicked off and can correctly identify which branch was updated. From what I have found, this means that my initial idea of a user-defined variable is not going to work any longer. Is there a predefined pipeline variable that I can use to tell which branch was checked into, so that that branch is the one that is checked out and built? If not, is there some other way to do this in one pipeline, or do I ultimately need to duplicate this build pipeline for each branch?
Sorry, it's not available with TFVC in Azure DevOps/TFS build pipeline.
For CI trigger, you could select the version control paths you want to include and exclude. In most cases, you should make sure that these filters are consistent with your TFVC mappings on the Repository tab. It's not able to dynamically set workspace mapping path based on the branch which continuous integration trigger your build pipeline.
You could also take a look at Daniel's explanation in this question: When my TFS build is triggered by a branch-specific check-in, why doesn't it set that branch as its source?
TFVC relies on workspace mappings to know what to download. The workspace mappings can encompass multiple TFVC repos across different
team projects, multiple branches within a single repository......
As a result, there's no way for it to understand how to dynamically change workspace mappings to be for a specific branch.
Conclusion: You may need one build for every branch, duplicate the pipeline simply change the path filters in trigger and workspace mappings.

How to "Pop-Up" a GUI on a build pipeline?

We are utilizing Azure Devops (TFS) build pipeline for managing a Git Repository/branches/stages (Dev/test/prod) and one thing that came up is the concept of "cherry-picking" commits. However, the user would have to supposedly look at the commit hash code and pass it in as argument to deploy that specific commit should a use case scenario arise like that.
The project manager has asked if we can make some sort of GUI pop-up at a certain step of the build pipeline that displays the list of these commit hashes and allows a user to check the boxes for the ones they'd want to cherry-pick and deploy.
How can that be done? we are considering utilizing Java with TFS/Azure Devops API's, but not sure if we can pop-up something like that on the Azure Devops page mid-pipeline deployment.
Build pipeline is not user interactive while running. So you can not pop up a gui on a build pipeline.
If you want to check the commits and pass the commits to build pipeline to build. You can first go to the Commits under Repos and check for the commits of a branch.
Then when you queue your build pipeline. You can click the dropdown menu for Branch/tag, select Commits, and then enter the commit id you get from above step. The build pipeline will then build the commit you entered.

How to automatically trigger a build after a PR is completed in Azure DevOps

Is there a way I can set up a build in Azure DevOps to automatically run every time a PR is merged and completed and contains a specific keyword in the name? for example: "Some PR name here [RUN_BUILD_123]"
Edit:
The reason for this is because I have different builds on top of the same branch so instead of triggering all the builds I just want to trigger those that I know need to be rebuilt based on the particular projects getting changed.
A PR has a target-branch. If you want to trigger a build after a PR is completed just configure a build with a ci-trigger for that target-branch. You can't check for certain keywords in the PR-name unfortunately
Agree with D.J. For detailed setting, you can check the Enable continous intergration option in the Triggers settings, then select the target branch you want ci-trigger build in the Branch filters.This will automatically trigger the build after pr is completed.
But you can't do it if you want to include special keywords in pr name.
Topic is a bit old, but if there is anyone who want's to archive this stumbling over this topic - here is my approach how I would solve this:
The basic of all are scripted pipelines, so if you still do it in the GUI - that's wasted time. Create a .yml build and put it into your Git. The M$ documentation is really helpful with this.
Create the trigger for your branch
Put this on the first line, so the pipeline will be executed when master (or your branch) has a new commit
trigger:
branches:
include:
- master
Read out the commit message via the VSTS variables
Trigger the builds, based on their ID via REST API (you can use the pipeline token for authentication)

Resetting build policy on branch update in VSTS / Azure DevOps

I'm using a build policy on one of my Azure DevOps git branches.
Is there any way of requiring a manually triggered branch build policy be run again if the source branch is updated?
My branch policy is set to Manual trigger. We use Manual instead of Automatic to reduce the number of builds (we use self hosted build server) running on our CI server as we typically open PR's early to provide feedback and facilitate conversation around code.
If the trigger was set to automatic, then any time source branch is updated a new build is queued. This isn't case with Manual. I had situation where build policy passed but then a further commit was made to branch and the reviewer approved. But the build was not manually triggered again and the last commit & push introduced a bug. I'd like the build validation policy to either reset or fail every time the source branch is updated similar to how code reviewer votes are reset after a push.
Is this possible?
I do not think this is currently possible, it has been raised on the Developer community as a feature request / issue, so I would encourage you to up-vote this here.
A solution for our scenario (too many builds were being queued, because Code Reviews come back with changes) was to use Pull Request drafts.
Sprint 143 - Draft Pull Request
When creating a PR, you can click Create as Draft in the drop down beside the Create button.