wiki.getshifting.com

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


cheatsheet-azuredevops
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cheatsheet-azuredevops [2025/10/25 18:06] – external edit 127.0.0.1cheatsheet-azuredevops [2025/11/09 15:11] (current) – [Working with Debug] sjoerd
Line 25: Line 25:
 Write-Host "##vso[task.logissue type=warning]Found something that could be a problem." Write-Host "##vso[task.logissue type=warning]Found something that could be a problem."
 </code> </code>
-\\+ 
 +=== 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:SYSTEM_DEBUG -eq "True"){$headers | Out-Host} if ($env:SYSTEM_DEBUG -eq "True"){$headers | Out-Host}
 </code> </code>
 +\\
 +> Run a task only when the debug is set
 +<code yaml>
 +- task: PowerShell@2
 +  displayName: "Get System Variables"
 +  condition: eq(variables['System.debug'], true)
 +  inputs:
 +    pwsh: true
 +    targetType: 'inline'
 +    script: |
 +      Write-Host "`n##[section]Get System Variables`n"
 +      Get-ChildItem -path env:* | Sort-Object Name
 +</code>
 +
 +==== Powershell: Use a verboseflag when the debug is set ====
 +
 +<code powershell>
 +# Set the verbose flag based on pipeline variable
 +if ($env:SYSTEM_DEBUG -eq "True"){
 +  Write-Host "##[debug]Verbose logging is enabled"
 +  $verboseFlag = $true
 +} else {
 +  $verboseFlag = $false
 +}
 +# Run commands only when the verboseflag has been set to true
 +if ($verboseFlag) {
 +  Write-Host "##[debug]Check current directory structure"
 +  Get-Location
 +  Get-ChildItem -Recurse
 +}
 +# Enable the verbose flag per command when the verboseflag has been set to true
 +New-Item -Path $vstsTaskSdkDir -ItemType "Directory" -Verbose:$verboseFlag
 +</code>
 +
  
 == Variables in Azure DevOps == == Variables in Azure DevOps ==
cheatsheet-azuredevops.1761415596.txt.gz · Last modified: by 127.0.0.1