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

Next revision
Previous revision
cheatsheet-azuredevops [2025/06/01 11:59] – created - 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 ==
Line 272: Line 308:
       Set-AzContext -Name ${{ parameters.environment }} -Subscription $env:azureSubscriptionName       Set-AzContext -Name ${{ parameters.environment }} -Subscription $env:azureSubscriptionName
 </code> </code>
 +
 +== 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: "Deploy steps"
 +  condition: false
 +</code>
 +//This wiki has been made possible by://
 +
 +<HTML>
 +<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8613096447910897"
 +     crossorigin="anonymous"></script>
 +<!-- Wiki End of Page -->
 +<ins class="adsbygoogle"
 +     style="display:block"
 +     data-ad-client="ca-pub-8613096447910897"
 +     data-ad-slot="6221699236"
 +     data-ad-format="auto"
 +     data-full-width-responsive="true"></ins>
 +<script>
 +     (adsbygoogle = window.adsbygoogle || []).push({});
 +</script>
 +</HTML>
 +
 +
  
cheatsheet-azuredevops.1748779162.txt.gz · Last modified: by 127.0.0.1