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

YAML if conditions don't expand variables #1733

Closed
AceHack opened this issue Jul 26, 2018 · 3 comments
Closed

YAML if conditions don't expand variables #1733

AceHack opened this issue Jul 26, 2018 · 3 comments

Comments

@AceHack
Copy link

AceHack commented Jul 26, 2018

I have the following parameter in a yaml build and it's set to 'yes' in VSTS variables tab.

parameters:
  buildDebugPackage: '$(BuildDebugPackage)'

I would like to do the following

- ${{ if eq(parameters.buildDebugPackage, 'yes') }}:
  - ${{ parameters.preBuildDebugProjects }}
  - task: DotNetCoreCLI@2
    displayName: Build Debug Projects
    inputs:
      projects: ${{ parameters.projects }}
      arguments: '--no-restore -c Debug /p:Version=$(ASSEMBLY_VERSION);FileVersion=$(FILE_VERSION)'
  - ${{ parameters.postBuildDebugProjects }}

But this does not work because the variable BuildDebugPackage is not expanded to the value 'yes'.

I have to instead do the following

- powershell: |
    Write-Host "##vso[task.setvariable variable=BuildDebugPackage]$($env:BuildDebugPackage)"
  displayName: Setup Environment Variables
  env:
    BuildDebugPackage: ${{ parameters.buildDebugPackage }}
  ignoreLASTEXITCODE: false
  errorActionPreference: Stop
  failOnStderr: true

- ${{ parameters.preBuildDebugProjects }}
- task: DotNetCoreCLI@2
  displayName: Build Debug Projects
  condition: and(succeeded(), eq(variables[BuildDebugPackage], 'yes'))
  inputs:
    projects: ${{ parameters.projects }}
    arguments: '--no-restore -c Debug /p:Version=$(ASSEMBLY_VERSION);FileVersion=$(FILE_VERSION)'
- ${{ parameters.postBuildDebugProjects }}

This is far inferior as I cannot even condition the pre and post steps. This also shows up on the UI as a skipped step instead of not showing up at all. I also have to convert the parameter to a variable in PowerShell as well. Please fix this bug or give a workaround. Thanks.

@ericsciple
Copy link
Contributor

@vtbassmatt fyi - this is basically the process parameters for yaml feature on our backlog.

@TingluoHuang
Copy link
Contributor

We have created a new repository for all YAML related issues, please move the current issue to there.
https://github.com/Microsoft/azure-pipelines-yaml

@ericsciple
Copy link
Contributor

@vtbassmatt fyi - here is a request for process parameters

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

3 participants