'How to debug Azure pipeline stage/job condition returning true when expecting false

I was setting up a condition to skip tests run for pipeline development purposes by setting variable skipTestsOnFeatureBranchName to current branch name. I could then leave it in place when ready to merge to master and have the tests still enabled on master.

I did not get it working right away though as I had one of the conditions backwards. Since I have had lots of trouble with variable syntax (and also had here initially as in conditions you cannot have dollar sign character used in elsewhere for all the condition syntax '$').

It seems that condition and all related variables are only expanded if the condition evaluates to false. So how should I go about debugging condition that evaluates to true, but I want it to be false?

Expanded condition when condition evaluates to false and job is skipped Image 1. Expanded condition when condition evaluates to false and job is skipped

Image 2. Condition is not expanded to output even when system diagnostics flag is enabled for the build. Image 2. Condition is not expanded to output even when system diagnostics flag is enabled for the build.

I had quite a git commit amend and force push spree to get this one working, but here is the version that works as I expect (skips the job when branch defined by skipTestsOnFeatureBranchName matches branchPath):

trigger:
  branches:
    include:
    - master
    - feature/*

pool:
  vmImage: ubuntu-latest

variables:
  fullBranchPath: $[variables['Build.SourceBranch']]  
  branchPath: $[replace(variables['fullBranchPath'],'refs/heads/', '')]  
  isMasterBranch: $[eq(variables['fullBranchPath'], 'refs/heads/master')]
  skipTestsOnFeatureBranchName: 'feature/skip_stage_on_branch'

stages:
  - stage:
    displayName: 'Stage to skip'
    jobs:
      - job:
        displayName: 'Job to skip'
        condition: or(eq(variables['isMasterBranch'], 'true'), and(eq(variables['isMasterBranch'], 'false'), ne(variables['branchPath'], variables['skipTestsOnFeatureBranchName'])))
        steps:
        - script: echo Hello, world!
          displayName: 'Run a one-line script'

The problem I had was that was with the last comparison in the condition having eq and not ne, so having all the variables logged would have surely help me arrive to the solution earlier. Maybe I should have just setup job variables and log them, but still I could have doubted if the condition syntax is correct as it differs from all other variable syntax:

diff --git a/azure-pipelines-test-condition.yml b/azure-pipelines-test-condition.yml
index cd28c33..d1f86d1 100644
--- a/azure-pipelines-test-condition.yml
+++ b/azure-pipelines-test-condition.yml
@@ -24,7 +24,7 @@ stages:
     jobs:
       - job:
         displayName: 'Job to skip'
-        condition: or(eq(variables['isMasterBranch'], 'true'), and(eq(variables['isMasterBranch'], 'false'), eq(variables['branchPath'], variables['skipTestsOnFeatureBranchName'])))
+        condition: or(eq(variables['isMasterBranch'], 'true'), and(eq(variables['isMasterBranch'], 'false'), ne(variables['branchPath'], variables['skipTestsOnFeatureBranchName'])))
         steps:
         - script: echo Hello, world!
           displayName: 'Run a one-line script'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source