question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditionally including tasks or templates not supported, "The first property must be a task"

See original GitHub issue

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#parameters-to-select-a-template-at-runtime

The preceding link describes a way to conditionally include templates based on parameters.

#azure-pipeline.yml
parameters:
- name: experimentalTemplate
  displayName: 'Use experimental build process?'
  type: boolean
  default: false

steps:
- ${{ if eq(parameters.experimentalTemplate, true) }}:
  - template: experimental.yml
- ${{ if not(eq(parameters.experimentalTemplate, true)) }}:
  - template: stable.yml

This extension does not see this as a valid template, resulting in error “The first property must be a task”.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
50Wliucommented, Feb 5, 2021

This is the same as #187, so closing in favor of that one. It’s on the todo list of things to tackle!

1reaction
jason-hacommented, Feb 2, 2021
...
steps:
- ${{ if eq(parameters.experimentalTemplate, true) }}:
  - template: experimental.yml
- ${{ if not(eq(parameters.experimentalTemplate, true)) }}:
  - template: stable.yml

@iTiamo I recommend using True/False in yaml. Canonical values are True/False rather than true/false. It normally doesn’t matter, but it can crop up and the subtle capitalization difference may be hard to spot. It bit my team once; so we just use True/False everywhere now. Also with a Boolean parameter there is no need for eq(parameters.experimentalTemplate, true), parameters.experimentalTemplate works well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error as unexpected property, First property must me ...
There is a clear bug with the UI here: There is no error running this yaml pipeline, the first property is a template...
Read more >
Azure YAML pipelines conditional insertion doesn't work
So, when we execute the pipeline, the conditional insertion ${{ if eq(variables['AppType'], 'WebJob') }} has already been evaluated, however, ...
Read more >
Templates - Azure Pipelines
In this article. Parameters; Extend from a template; Extend from a template with resources; Use templateContext to pass properties to templates ...
Read more >
Task definition parameters - Amazon ECS
A port can only be included in one port mapping per container. You cannot specify overlapping port ranges. The first port in the...
Read more >
React interactivity: Editing, filtering, conditional rendering
A task should only render if it is included in the results of applying the selected filter. Before we map over the tasks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found