HiveBrain v1.2.0
Get Started
← Back to all entries
snippetyamlterraformMinor

How to test pipeline changes in Azure?

Submitted by: @import:stackexchange-devops··
0
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?

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,

parameters:
  - name: DebugMode
    displayName: Skip Deployments and run in DebugMode
    type: string
    default: false
    values:
    - false
    - true


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.

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 $buildNumber

Code Snippets

parameters:
  - name: DebugMode
    displayName: Skip Deployments and run in DebugMode
    type: string
    default: false
    values:
    - false
    - true
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 $buildNumber

Context

StackExchange DevOps Q#13282, answer score: 1

Revisions (0)

No revisions yet.