snippetyamlterraformMinor
How to test pipeline changes in Azure?
Viewed 0 times
azurechangestesthowpipeline
Problem
I currently have a pipeline in Azure which consists of a bunch of YAML which eventually calls some terraform script to handle the deployment side.
What is the best way to handle dev testing of changes to the pipeline?
For example, i want to add a new task in the YAML. There doesnt seem to be a way to test this without actually performing and completing a pull request.
I the cases where i do something wrong and the pipeline (say an invalid parameter value) fails i need to do a whole new checkin, push, pull request, merge and then wait for the pipeline to complete or fail.
There has to be a better way?
What is the best way to handle dev testing of changes to the pipeline?
For example, i want to add a new task in the YAML. There doesnt seem to be a way to test this without actually performing and completing a pull request.
I the cases where i do something wrong and the pipeline (say an invalid parameter value) fails i need to do a whole new checkin, push, pull request, merge and then wait for the pipeline to complete or fail.
There has to be a better way?
Solution
Not sure if this helps you? but if you edit it from the portal you can select the branch you are working on and there is a validate option
I also add a parameter to my pipelines,
Which adds a radio button when you run the Pipeline
and then I have a condition to skip the actual deployment task for the debug mode so I can test the logic of my pipelines running them from teh branch I am working on before PR the change in to main.
I also add a parameter to my pipelines,
parameters:
- name: DebugMode
displayName: Skip Deployments and run in DebugMode
type: string
default: false
values:
- false
- trueWhich adds a radio button when you run the Pipeline
and then I have a condition to skip the actual deployment task for the debug mode so I can test the logic of my pipelines running them from teh branch I am working on before PR the change in to main.
steps:
- ${{ if eq(parameters.DebugMode, false) }}:
- task: Deploy
inputs:
....
- ${{ if eq(parameters.DebugMode, true) }}:
- task: PowerShell@2
name: DummyDeployment
displayName: 'Dummy Do Nothing'
continueOnError: false
inputs:
targetType: Inline
script: |
echo "In Debug mode running Dummy Deployment"
echo $buildNumberCode Snippets
parameters:
- name: DebugMode
displayName: Skip Deployments and run in DebugMode
type: string
default: false
values:
- false
- truesteps:
- ${{ if eq(parameters.DebugMode, false) }}:
- task: Deploy
inputs:
....
- ${{ if eq(parameters.DebugMode, true) }}:
- task: PowerShell@2
name: DummyDeployment
displayName: 'Dummy Do Nothing'
continueOnError: false
inputs:
targetType: Inline
script: |
echo "In Debug mode running Dummy Deployment"
echo $buildNumberContext
StackExchange DevOps Q#13282, answer score: 1
Revisions (0)
No revisions yet.