#Azure Pipelines - Unsure why stage is skipping 100% of the time

1 messages ยท Page 1 of 1 (latest)

empty scroll
#

Hi there,

I have a test script consisting of 3 stages. In order, one stage runs CI tests, then one bumps the version of the software, then finally builds the app.

When deploying, we should be able to skip this version bump if we don't want to do it. Therefore, stage 3 should run if the other two stages have succeeded or skipped, but never failed.

I've got this working in GitHub Actions and am currently trying to port this over to Azure Pipelines. So far, it looks like this.

# Test stage template, leads to stage called `run_tests_stage`
- template: test-stage.yml

- stage: 'version_bump_stage'
  .....


- stage: 'Build'
    displayName: 'Build React Native App'
    dependsOn:
      - run_tests_stage
      - version_bump_stage
    condition: |
      and(
        not(canceled()),
        in(dependencies.run_tests_stage.result, 'Skipped', 'Succeeded'),
        in(dependencies.version_bump_stage.result, 'Skipped', 'Succeeded')
      )
    jobs:
      - job: 'build_android'
      ......

Both of the first two stages always pass, yet the "Build" stage always skips. I cannot figure out why. I've been trying all day to print the outputs of these conditions, but I keep getting other errors here, likely due to my inexperience.

Where have I gone wrong here? Any answers or help with pointing me in the right direction to further debug this would be much appreciated.

Thanks! ๐Ÿ™

dreamy ginkgo
#

Would it be possible that your stages' result is "SucceededWithIssues" ?

#

(at least one of them)

empty scroll
dreamy ginkgo
#

Nope, but maybe it shows in the pipeline execution

#

You can also try adding 'SucceededWithIssues' next to Succeeded and Skipped

empty scroll
# dreamy ginkgo Nope, but maybe it shows in the pipeline execution

I did try to print them via adding a job to the build stage like this:

- job: 'test'
        displayName: 'Test'
        pool:
          vmImage: 'ubuntu-latest'
        variables:
          testStage: $[ stageDependencies.run_tests_stage.result ]
          verBumpStage: $[ stageDependencies.version_bump_stage.result ]
    
        steps:
          - script: echo $(testStage) , $(verBumpStage)

This output " , " when actually ran, and I grabbed this screenshot from the console

#

I'll give SucceededWithIssues a go now, although I'd like to know what would qualify as an "issue" if this is the case

dreamy ginkgo
#

Don't know, but I found a similar code to yours on SO that includes this

#

Here's the corresponding doc

empty scroll
#

Thanks! I appreciate the link, but I've had that open in a tab all day trying to debug this ๐Ÿ˜†

empty scroll
# dreamy ginkgo You can also try adding 'SucceededWithIssues' next to Succeeded and Skipped

Skipped right over ๐Ÿ˜ฉ

For reference, it now looks like:

- stage: 'Build'
    displayName: 'Build React Native App'
    dependsOn:
      - run_tests_stage
      - version_bump_stage
    condition: |
      and(
        not(canceled()),
        in(dependencies.run_tests_stage.result, 'Skipped', 'Succeeded', 'SucceededWithIssues'),
        in(dependencies.version_bump_stage.result, 'Skipped', 'Succeeded', 'SucceededWithIssues')
      )
    jobs:
dreamy ginkgo
#

There's a weird thing in your screenshot

#

You have two dependencies, shouldn't you have to links going into Build React ?

empty scroll
#

The jobs are currently made to run synchronously, as I've only got one parallel runner on the free plan (so not parallel at all! ๐Ÿ˜…)

dreamy ginkgo
#

I assume run CI tests is run_tests_stage ?

#

Maybe provide the code from test-stage.yml

empty scroll
#

Correct! Here it is

#

Full code for this file is

stages:
  - stage: 'run_tests_stage'
    displayName: 'Run CI Tests'
    jobs:
      - job: 'run_tests_job'
        displayName: 'Run CI Tests'
        pool:
          vmImage: 'ubuntu-latest'

        steps:
          - checkout: self
            persistCredentials: true
            clean: true

          - task: NodeTool@0
            displayName: 'Install Node'
            inputs:
              versionSpec: '16.16.0'

          - script: npm i -g cross-env --legacy-peer-deps
            displayName: Install cross-env

          - script: npm run github-actions-android-install
            displayName: Install NPM dependencies

          - script: npm run test:ci
            displayName: Run NPM Tests

          - task: PublishTestResults@2
            displayName: Publish Test Results
            inputs:
              testResultsFormat: 'JUnit'
              testResultsFiles: 'reports/jest-*.xml'
#

At this point, it shouldn't matter, as I'm choosing to skip the test stage via the Azure Run Menu. I only choose to run the "Version Bump" and "Build React Native App" stages

dreamy ginkgo
#

Did you try removing both in conditions, check if stage runs, then put one back in, check again, etc. ?

dreamy ginkgo
#

Also, not sure it will help but can you try running the same pipeline but removing the dependson section ?

#

(in the Build stage)

#

Remove the dependsOn, keep the condition

empty scroll
#

@dreamy ginkgo Hi there! Should hopefully have some answers for you shortly; I've broken the condition up like so, which should give us some answers.

  - stage: 'test_not_cancelled'
    displayName: 'test_not_cancelled'
    dependsOn:
      - run_tests_stage
      - version_bump_stage
    condition: |
      not(canceled())
    jobs:
      - job: 'test_job'
        displayName: 'aa'
        pool:
          vmImage: 'ubuntu-latest'

        steps:
          - script: echo PING
            displayName: test echo ping

  - stage: 'ver_bump_any_status'
    displayName: 'ver_bump_any_status'
    dependsOn:
      - run_tests_stage
      - version_bump_stage
    condition: |
      and(
        not(canceled()),
        in(dependencies.version_bump_stage.result, 'Skipped', 'Succeeded', 'SucceededWithIssues', 'Failed', 'Canceled')
      )
    jobs:
      - job: 'test_job'
        displayName: 'aa'
        pool:
          vmImage: 'ubuntu-latest'

        steps:
          - script: echo PING
            displayName: test echo ping

  - stage: 'run_tests_any_status'
    displayName: 'run_tests_any_status'
    dependsOn:
      - run_tests_stage
      - version_bump_stage
    condition: |
      and(
        not(canceled()),
        in(dependencies.run_tests_stage.result, 'Skipped', 'Succeeded', 'SucceededWithIssues', 'Failed', 'Canceled')
      )
    jobs:
      - job: 'test_job'
        displayName: 'aa'
        pool:
          vmImage: 'ubuntu-latest'

        steps:
          - script: echo PING
            displayName: test echo ping
#

I initially had the bottom two stages joined together, and that still skipped over. I'm starting to suspect if you choose to skip over a specific stage in the Azure menu (via the checkboxes before starting a run), it doesn't register the stage as skipped

#

It's certainly starting to look that way

#

Using the Azure Build Timeline API to pull out the resolved conditions, I've found the following:

### THIS IS THE EVALUATED CONDITION FOR THE 'run_tests_any_status' STAGE
Evaluating: and(not(canceled()), in(dependencies['run_tests_stage']['result'], 'Skipped', 'Succeeded', 'SucceededWithIssues', 'Failed', 'Canceled'))

Expanded: and(not(False), in(Null, 'Skipped', 'Succeeded', 'SucceededWithIssues', 'Failed', 'Canceled'))

Result: False

###
---------------------------
###

### THIS IS THE EVALUATED CONDITION FOR THE 'Build' STAGE
Evaluating: and(not(canceled()), in(dependencies['run_tests_stage']['result'], 'Skipped', 'Succeeded', 'SucceededWithIssues'), in(dependencies['version_bump_stage']['result'], 'Skipped', 'Succeeded', 'SucceededWithIssues'))

Expanded: and(not(False), in(Null, 'Skipped', 'Succeeded', 'SucceededWithIssues'), in(dependencies['version_bump_stage']['result'], 'Skipped', 'Succeeded', 'SucceededWithIssues'))

Result: False
dreamy ginkgo
#

That's interesting

#

Did you try removing the dependsOn ?

empty scroll
#

Also sorry for the sparse replies, Discord breaking for everyone at the moment and blocks me for 15 minutes every 2 messages

dreamy ginkgo
#

(so the doc would need some correction if it doesn't work)

empty scroll
dreamy ginkgo
#

I need to find that back, it was yesterday ๐Ÿ˜„

#

I'll tell you if I find the part of the doc where I also saw that

empty scroll
empty scroll
dreamy ginkgo
#

That's good to know

empty scroll
#

Hopefully the hair I lost with this issue saves you a few strands ๐Ÿ˜‚

dreamy ginkgo
#

Yeah ๐Ÿ˜„

empty scroll
#

Also thanks for all your help these last couple of days!

dreamy ginkgo
#

You're welcome ^^

empty scroll
#

@dreamy ginkgo Just keeping you in the loop here, if I change the condition like so:

and(
  not(canceled()),
  in(dependencies.version_bump_stage.result, 'Skipped', 'Succeeded', 'SucceededWithIssues', '')
)

Assuming that this stage will only EVER be null because I've told it not to run on the Azure UI, this provides the functionality I want, as '' matches any value reading Null

However, this is still a dumb workaround that requires a second pair of eyes from someone at MS, but at least it means I'm not blocked on anything :))

dreamy ginkgo
#

I hope you'll have an answer somewhere !

empty scroll
#

Me too man ๐Ÿ’€

dreamy ginkgo
#

I'm wondering if changing the conditions to :

not(failed('stage_name'))

Wouldn't work even better

#

So something like

not(canceled('stage1')), not(failed('stage1')),
not(canceled('stage2')), not(failed('stage2'))
)```