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

[Question]: How to do multiple conditions in a pipeline #4887

Open
1 of 4 tasks
GBCSIM1 opened this issue Jul 8, 2024 · 1 comment
Open
1 of 4 tasks

[Question]: How to do multiple conditions in a pipeline #4887

GBCSIM1 opened this issue Jul 8, 2024 · 1 comment

Comments

@GBCSIM1
Copy link

GBCSIM1 commented Jul 8, 2024

Describe your question

I am looking to do multiple conditions in my pipeline which includes my parameters file and a value

Here is my paramters at the top of the Page:
parameters:

  • name: lzFileName
    displayName: 'LandingZone file name'
    type: string
    default: 'ccc_npd_testing.json'
  • name: serviceConnection
    displayName: 'Service connection name'
    type: string
  • name: doWhatIf
    displayName: 'Only do What If'
    type: boolean
    default: false
  • name: operationType
    displayName: 'operationType'
    type: string
    values: ['Create', 'Update']
    default: 'Create'
  • name: branchName
    displayName: 'Branch name of subscription'
    type: string

so originally i had one condition which if the update is selected on the pipeline:

  • ${{ if startsWith(parameters.operationType, 'Update')}}:
    this works great.

However I want to add it so if its not equal to a 0 value on parameters file for budgetAmount:

  • ${{ if startsWith(parameters.operationType, 'Update'), ne(parameters.budgetAmount.value, '0')}}:

This doesn't work. Any ideas? The parameter for the budget is specified within the code so not right at the top of the page.

Versions

ubuntu-latest

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

ubuntu-latest

Version controll system

No response

Azure DevOps Server Version (if applicable)

No response

@DmitriiBobreshev
Copy link
Contributor

Hi @GBCSIM1, unfortunately, runtime parameters are only available before the job started and not on the agent's side.

What you can do is add a condition to your pipeline. The conditions are evaluated before each step/job on the agent's side, so if you change the value of parameter/variable in some step, it will have an actual state when conditions are evaluated.

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

No branches or pull requests

2 participants