Difference between revisions of "Azure/Azure Devops + az extension"

From Ever changing code
Jump to navigation Jump to search
Line 56: Line 56:
</source>
</source>


= Pipeline variables =
= Pipeline [https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch variables] =
Variables are available in expressions as well as scripts; see variables to learn more about how to use them. There are some predefined build and release variables you can also rely on.
Variables are available in expressions as well as scripts; see variables to learn more about how to use them. There are some predefined build and release variables you can also rely on.
Syntax
Syntax

Revision as of 00:13, 2 September 2020

What is Azure DevOps:

  • Azure Repos - SCM/VCS system hosted in Azure
  • Azure Pipelines - Build, test, release automations
  • Azure Boards - Kanban board; JIRA like to track work, code defects, issues using Kanban or Scrum
  • Azure Test Plans
  • Azure Artifacts - share Maven, npm, NuGet from private and public sources

dotnet commands reference

dotnet restore **/*.csproj # Restores the dependencies and tools of a project
dotnet build               # Builds a project and all of its dependencies
dotnet test **/*[Tt]ests/*.csproj # .NET test driver used to execute unit tests
dotnet publish # Publishes the application and its dependencies to a folder for deployment to a hosting system

az-cli with azure-devops extension

<syntaxhighlightjs lang="bash"> az extension list az extension show --name azure-devops az extension add --name azure-devops [

 {
   "experimental": false,
   "extensionType": "whl",
   "name": "azure-devops",
   "path": "/home/piotr/.azure/cliextensions/azure-devops",
   "preview": false,
   "version": "0.18.0"
 }

] az login # login to get subscription level authentication az devops login # login to Azure DevOps Token: **** # <- generate a token in AzureDevops > UserSerrings > Personal tokens

  1. Optional set default organization and project, or add them per each command

az devops configure --defaults organization=https://dev.azure.com/contoso project=ContosoWebApp

    1. List all repos
  1. Linux

az repos list --organization=https://dev.azure.com/contoso/ --project=ContosoWebApp --query '[].{Name:name, Url:remoteUrl}' -o json | jq -r .[].Name

  1. PowerShell

(az repos list --query '[].{Name:name, Url:remoteUrl}' -o json | ConvertFrom-Json) | %{ git clone $_.Url } </syntaxhighlightjs>

Azure pipeline agents

Software included:

Environment:

# Default working directory, also where repos get cloned
$(Build.SourcesDirectory): /home/vsts/work/1/s

# Published artifacts
cd ../name-of-artifact/

Pipeline variables

Variables are available in expressions as well as scripts; see variables to learn more about how to use them. There are some predefined build and release variables you can also rely on. Syntax

regionName    : "${{ variables.aws_region }}"
regionName    : $(aws_region)

Resources

Code Assessment Tools