-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YAML] Calculate value for task input using conditions #1727
Comments
Thanks I was able to repro the bug. Here is a workaround: # build.package.yml
parameters:
force: false
override: false
steps:
- checkout: self
clean: true
- ${{ if and(ne(parameters.force, 'false'), ne(parameters.override, 'false')) }}
- task: DownloadBuildArtifacts@0
displayName: Download Build Artifacts
condition: and(succeeded(), in(variables['build.reason'], 'Manual', 'Schedule'))
continueOnError: true
inputs:
buildType: specific
downloadType: specific |
In the expressions, all scalar parameters are interepreted as strings and |
...so I switched your expression to use |
@ericsciple thanks. Workaround is working I've just added ':' to the end of the line.
So that means, for example with ${{ not(parameters.force) }}: P.S. Should this issue remain opened or can be closed? |
@t3mi let's leave it open for now. Your assessment regarding I found the bug. Thanks for reporting this. When I get a fix in, and an ETA when it will be deployed, I'll update the work item here and likely close it then. |
@ericsciple just to be sure I follow you on what is going on here based on feedback from @t3mi :
Does it means parameters in templates don't follow their YAML type?
Does it means expanded expression will always be of type string? Lastly, are those assertion going to be default behaviors for GA? |
@ggirard07 That's correct. As far as we're concerned when we are building the yaml DOM, everything is string, sequence, or mapping. Expressions support Boolean, number, string, datetime, and complex types. But when the expressions is evaluated the result should always be convert to string, sequence, or mapping. (currently there is a bug, because Boolean is not getting converted to string; i'm working on a fix right now) |
@vtbassmatt fyi, there are good details in this issue we need to capture in the docs. i'll create a user story on the internal backlog and paste relevant portions from this issue. |
We have created a new repository for all YAML related issues, please move the current issue to there. |
Have you tried trouble shooting?
Couldn't queue the build
Agent Version and Platform
Version of your agent?
2.136.1
OS of the machine running the agent?
CentOS 7 x64 7.5
VSTS Type and Version
VSTS
What's not working?
According to templateexpressions there is a possibility to use task condition for the templates. I've tried to use next value for one of the task input ${{ and(not(parameters.force), not(parameters.override)) }} and it wasn't calculated properly. Limiting value to just one function ${{ not(parameters.force) }} throws the same error. I want to have task enabled/disabled depending on the value of two parameters. Is it possible?
Error in VSTS while trying to queue a build:
build.package.yml (Line: 13, Col: 14): Unexpected type: 'System.Boolean',build.package.yml (Line: 13, Col: 14): Expected a Boolean value. Actual value: ''
The text was updated successfully, but these errors were encountered: