Skip to content
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

Using succeeded() in Template Expressions #33

Closed
JeremyTCD opened this issue Oct 30, 2018 · 2 comments
Closed

Using succeeded() in Template Expressions #33

JeremyTCD opened this issue Oct 30, 2018 · 2 comments

Comments

@JeremyTCD
Copy link

Description

I have a job in a template that depends on a preceding job as well as a template parameter:

parameters:
  runTests: true

# omitted for brevity

- job: "Test"
  dependsOn: "Build"
  condition: ${{and(parameters.runTests, succeeded())}}

I'm trying to use the succeeded() job status function within a template expression to ensure that the job only runs if "Build" succeeded and "runTests" is true. Unfortunately, it seems like this isn't allowed - the job "Test" fails with an error message stating that "succeeded" is invalid.

I've tried

and(${{parameters.runTests}}, succeeded())

as well.

Is there a way to evaluate parameters and job status functions in a single boolean expression?

@ericsciple
Copy link
Contributor

No, the ${{ }} expressions are evaluated when compiling the plan.

It sounds like this is what you want:

parameters:
  runTests: true

- ${{ if eq('true', parameters.runTests) }}:
  - job: "Test"
    dependsOn: "Build"

@JeremyTCD
Copy link
Author

No, the ${{ }} expressions are evaluated when compiling the plan.

Ah okay I get it now. Yeah the conditional insertion is what I needed, somehow didn't occur to me that they can be used for jobs. Thanks for the tip!

Link to documentation on conditional insertion for anyone else with similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants