0

I have below main YML pipeline

enter image description here

And below is the template that is being called.

enter image description here

When trying to run the main pipeline is showing the error per below enter image description here

sharad jain
  • 113
  • 1
  • 10

2 Answers2

0

It looks that your condition is not met. So envname is not sbx and thus your template is skipped, and you can't run pipeline without any stage. Please make sure you have always at least one stage regardless of the result of the condition, or sth like empty stage for non sbx env.

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
0

Agree with Krzysztof Madej.

When you add condition to the stages level, you need to make sure that there is at least one stage that meets the condition at all times.

In addition to adding an empty stage, you could also add the negative condition in the Yaml sample:

For example:

stages:
- ${{if eq(variables['envName'],'sbx')}}:
  - template: test.yml
    parameters:
     buildSteps: test
- ${{if ne(variables['envName'],'sbx')}}:
  - stage: Test
    jobs:
    - job: TestJob
      steps:
        - script: echo Test
          displayName: 'Test Stage'
    

In this case, if the envName = sbx, it will run the template, or it will run another stage.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • Thanks yeah.. my condition was false... sorry couldnt get earlier. – sharad jain Dec 03 '20 at 05:58
  • @sharadjain Yes. This is the root cause of this issue. In this case, you need to add another stage to ensure that there is a valid value under the Stages level. Glad to know that this issue has been resolved. – Kevin Lu-MSFT Dec 03 '20 at 06:01