Home > Blockchain >  How to read variable as a Number in Azure DevOps Pipelines?
How to read variable as a Number in Azure DevOps Pipelines?

Time:07-20

I have an Azure DevOps Build Pipeline YAML file that takes variables from the 'Variables' button as opposed to having "variables:" in the YAML file itself.

I'm trying to pass a Number to a step that requires a Number as the parameter, however the pipeline is failing to run because it's saying the value is not a valid Number.

Inside the "Variables" button, I have the variable VersionId with the given value 12345.

extends:
  template: Directory/To/The/Template.yaml@Name
  parameters:
    projectVersionId: $(VersionId)

Is there a way I can explicitly state that this a number, and not a string?

I have tried using both ${{variables.VersionId}} and $[variables.VersionId]

CodePudding user response:

Try $[ variables['VersionId'] ]

This somewhat explains the reason why this works enter image description here

  • Related