Fairly new to Azure DevOps and using it for Infrastructure as Code Azure deployments.
Using Classic release pipelines, you can go into the pipeline, into a Stage and very quickly enable/disable tasks within that Stage
How would you do this with YAML pipelines?
You can try set variables : enabled = false , then use the variable in YAML file. If set this way, this task will not run in the job.
Overview. Many teams prefer to define their build and release pipelines using YAML (YAML Ain't Markup Language). This allows them to access the same pipeline features as those using the visual designer, but with a markup file that can be managed like any other source file.
In my case, the pipeline is called Build, and I will click on the pipeline's options and click on Settings on the right corner, as shown in the screenshot below. I will set the “Processing of new run requests” from the options page to disabled.
Azure Pipelines supports continuous integration (CI) and continuous delivery (CD) to continuously test, build, and deploy your code. You accomplish this by defining a pipeline. The latest way to build pipelines is with the YAML pipeline editor. You can also use Classic pipelines with the Classic editor.
In addition to comment out tasks with #
, here I provide another workaround :
You can try set variables : enabled = false
, then use the variable in YAML file.
steps:
- task: PublishSymbols@2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
enabled: false
continueOnError: true
If set this way, this task will not run in the job.
This method is mentioned in this case, you can refer to it for details.
Now with runtime parameters you have a GUI option. If you de-select the checkbox (see pic below) then you can pass that parameter to the pipeline.
There are [to my knowledge] three methods of implementing the runtime parameter in tasks and you can also apply most of logic in jobs/stages (with the exception that jobs/stages don't [currently] have an 'enabled' property);
parameters:
- name: RunTask
displayName: Run task?
type: boolean
default: true
steps:
- pwsh: Write-Host "always run this task"
- pwsh: Write-Host "skip this task when checkbox unticked..."
condition: eq(${{ parameters.RunTask }}, true)
- pwsh: Write-Host "skip this task when checkbox unticked..."
enabled: ${{ parameters.RunTask }}
- ${{ if eq(parameters.RunTask, true) }}:
- pwsh: Write-Host "skip this task when checkbox unticked..."
- ${{ if parameters.RunTask }}:
- pwsh: Write-Host "skip this task when checkbox unticked..."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With