Azure DevOps Server 2020 Do’s & Don’t
Azure DevOps Server 2020Permalink
Did you know Azure DevOps Services and Azure DevOps Server are different entities? I have learned lessons while working on Azure DevOps Server 2020 on-premise pipelines. In this article, I would share all of them so that you don’t repeat the mistake and get benefited.
Azure DevOps Vs Azure DevOps ServerPermalink
Azure DevOps Services: If you are working on dev.azure.com portal then you are using Azure DevOps Services. Most of the facilities you will get here. Microsoft is also focusing more on this portal to provide excellent services. I also supports
universal packages such as
Cache task etc.
Azure DevOps Server: If you are using Azure DevOps on your premise. Just like you were doing while using TFS on premise. Then it is called as Azure DevOps Server.
Universal Packages are not supported in Azure DevOps Server as of now.
Azure DevOps Server 2020Permalink
In this article I will explain my learning from Azure DevOps Server 2020 only. In my company we are using Azure DevOps Server 2020 And my machines are WINDOWS Operating Systems. If you are also using on-premise Azure DevOps with Windows OS then continue reading this article.
Defining Build Agent Pool NamePermalink
In your Pipeline
YML file make sure you define correct
Build Pool Name. If you put
default then It will take the default pool from your portal settings and use default agent as well. Which is not recommended.
Option 1: Define the Build Agent Pool Name from DevOps EditorPermalink
Build Agent Pool will actually point to a physical build machine. So by doing this you are dictating Azure DevOps server to build your code on a particular machine.
You can define the Build Agent Pool from Editor.
- Edit your CI/CD pipeline
- Select Trigger option
- Select your Agent Pool Name
Option 2: Defining the Build Agent Pool in YML filePermalink
Another option is to define pool name on your
Using PowerShell Task instead of Script TaskPermalink
If your on-premise azure server machine is windows one then always prefer
powershell task over
script. I love to use
script task. script task In Windows Azure Server refers to
command line scripts only. However, I have very bad experience executing node.js scripts using
script task in azure pipeline. It behaves very weirdly. I would therefore, advise even though it is very prompting to use
script don’t use it.
👍 Rule of thumb is: Use PowerShell task when you want to execute node.js scripts on build machine.
JSON across Azure Pipeline TaskPermalink
Sharing JSON across the azure pipeline task is common thing. Suppose you have a node.js script that returns a JSON structure all the commands you want to execute. That JSON you wan to use in next task.
The simple way that works in
ubuntu Azure DevOps Services. However, in windows on-premise Azure DevOps Server 2020 below is the way to use JSON across tasks.
Task 1 is returning a JSON
# in script1.js
Write-Host "##vso[task.setvariable variable=COMMANDS]$commands"
In Task 2 Using the JSON Shared from Task 1
# in script2.js
/* note here the json will come as string
* and JSON.parse(process.argv) won't work.
* You must use eval to assign
* the json in global variable.
const projects = commands['build'];
node script1.js $(COMMANDS)
Tagging Git Branch on Azure DevOpsPermalink
The recommended way to tag the Git Branch in Azure DevOps Server is to tag from the Pipeline Editor.
Follow the steps to tag your branch.
- Select YAML
- Select Get Sources
- On Build Success I will tag. Feel free to choose whichever option you want.
- Build Number as Tag Format. You can use something else for Tagging.
If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.
Originally published here.