cheatsheet-azuredevops
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| cheatsheet-azuredevops [2025/06/01 11:59] – created - external edit 127.0.0.1 | cheatsheet-azuredevops [2025/11/09 15:11] (current) – [Working with Debug] sjoerd | ||
|---|---|---|---|
| Line 25: | Line 25: | ||
| Write-Host "## | Write-Host "## | ||
| </ | </ | ||
| - | \\ | + | |
| + | === Working with Debug === | ||
| > Generate extra output if debug mode is set | > Generate extra output if debug mode is set | ||
| <code powershell> | <code powershell> | ||
| if ($env: | if ($env: | ||
| </ | </ | ||
| + | \\ | ||
| + | > Run a task only when the debug is set | ||
| + | <code yaml> | ||
| + | - task: PowerShell@2 | ||
| + | displayName: | ||
| + | condition: eq(variables[' | ||
| + | inputs: | ||
| + | pwsh: true | ||
| + | targetType: ' | ||
| + | script: | | ||
| + | Write-Host " | ||
| + | Get-ChildItem -path env:* | Sort-Object Name | ||
| + | </ | ||
| + | |||
| + | ==== Powershell: Use a verboseflag when the debug is set ==== | ||
| + | |||
| + | <code powershell> | ||
| + | # Set the verbose flag based on pipeline variable | ||
| + | if ($env: | ||
| + | Write-Host "## | ||
| + | $verboseFlag = $true | ||
| + | } else { | ||
| + | $verboseFlag = $false | ||
| + | } | ||
| + | # Run commands only when the verboseflag has been set to true | ||
| + | if ($verboseFlag) { | ||
| + | Write-Host "## | ||
| + | Get-Location | ||
| + | Get-ChildItem -Recurse | ||
| + | } | ||
| + | # Enable the verbose flag per command when the verboseflag has been set to true | ||
| + | New-Item -Path $vstsTaskSdkDir -ItemType " | ||
| + | </ | ||
| + | |||
| == Variables in Azure DevOps == | == Variables in Azure DevOps == | ||
| Line 272: | Line 308: | ||
| Set-AzContext -Name ${{ parameters.environment }} -Subscription $env: | Set-AzContext -Name ${{ parameters.environment }} -Subscription $env: | ||
| </ | </ | ||
| + | |||
| + | == Jobs == | ||
| + | |||
| + | Disable a job: As there isn't an option to disable a job in the pipeline, the best way is to use a condition: | ||
| + | |||
| + | <code yaml> | ||
| + | jobs: | ||
| + | - job: deploy | ||
| + | displayName: | ||
| + | condition: false | ||
| + | </ | ||
| + | //This wiki has been made possible by:// | ||
| + | |||
| + | < | ||
| + | <script async src=" | ||
| + | | ||
| + | <!-- Wiki End of Page --> | ||
| + | <ins class=" | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | < | ||
| + | | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
cheatsheet-azuredevops.1748779162.txt.gz · Last modified: by 127.0.0.1
