0
votes

I'm authoring an Azure Pipelines YAML file. I'd like a value to be sent in from the "outside" when the pipeline runs. How can I do this?

I've read this documentation but it's too dense, or I'm too dense, and I'm finding it hard to discern my simple use-case.

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch

1

1 Answers

2
votes

In your YAML, use the syntax $(myVariableName). You can concatenate this into string values.

Here's an example:

- task: AzurePowerShell@4
  displayName: Deploy ARM template
  inputs:
    inline: 'New-AzResourceGroupDeployment -ResourceGroupName $(azureResourceGroup) -TemplateFile $(System.DefaultWorkingDirectory)/build/$(armTemplateJsonFileName)'
  ...

The variables azureResourceGroup and armTemplateJsonFileName can then be configured within the web UI of the Pipeline as per the screenshot below. It will turned into an environment variable when the pipeline runs, so its also accessible to any scripts you run.

Screenshot of Azure Pipelines web portal variable editor