Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
For some workflows, you need your build pipeline to run Git commands. For example, after a CI build on a feature branch is done, the team might want to merge the branch to main.
Before you begin, be sure your account's default identity is set with the following code.
This must be done as the very first step after checking out your code.
Grant version control permissions to the build service
Go to the project settings page for your organization at Organization Settings > General > Projects.
Select the project you want to edit.
Within Project Settings, select Repositories. Select the repository you want to run Git commands on.
Select Security to edit your repository security.
Search for Project Collection Build Service. Choose the identity {{your project name}} Build Service ({your organization}) (not the group Project Collection Build Service Accounts ({your organization})). By default, this identity can read from the repo but can’t push any changes back to it. Grant permissions needed for the Git commands you want to run. Typically you'll want to grant:
If you see this page, select the repo, and then select the link:
On the Version Control tab, select the repository in which you want to run Git commands, and then select Project Collection Build Service. By default, this identity can read from the repo but can’t push any changes back to it.
Grant permissions needed for the Git commands you want to run. Typically you'll want to grant:
Create branch: Allow
Contribute: Allow
Read: Allow
Create tag: Allow
When you're done granting the permissions, make sure to select Save changes.
You want a CI build to merge to main if the build succeeds.
On the Triggers tab, select Continuous integration (CI) and include the branches you want to build.
Create merge.bat at the root of your repo:
bat
@echo off
ECHO SOURCE BRANCH IS %BUILD_SOURCEBRANCH%IF%BUILD_SOURCEBRANCH% == refs/heads/main (
ECHO Building main branch so no merge is needed.
EXIT
)
SET sourceBranch=origin/%BUILD_SOURCEBRANCH:refs/heads/=%ECHO GIT CHECKOUT MAIN
git checkout main
ECHO GIT STATUS
git status
ECHO GIT MERGE
git merge %sourceBranch% -m "Merge to main"
ECHO GIT STATUS
git status
ECHO GIT PUSH
git push origin
ECHO GIT STATUS
git status
My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?
This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Node.js documentation for more details about this variable. See Set variables in a pipeline for instructions on setting a variable in your pipeline.
I use TFS on-premises and I don't see some of these features. Why not?
This certification measures your ability to accomplish the following technical tasks: Design and implement processes and communications, design and implement a source control strategy, design and implement build and release pipelines, develop a security and compliance plan, and implement an instrumentation strategy.