I would like to use the name or id of the pull req...
# azure
r
I would like to use the name or id of the pull request as a suffix while naming my resources during deployment. What would be the best way to achieve this?
p
@rhythmic-vegetable-87369 assuming you are using Azure Pipelines, you can map pipeline variables into environment variables using the
env
property on the step in your pipeline YAML.
I’m not sure exactly what you mean by “name or id of the pull request” and I don’t think there’s a pipeline variable that represents that. You can check the variable references here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables
But you could for example use the
Build.SourceVersion
variable which represents the Git commit ID.
So you could do something like this in your YAML:
Copy code
- task: Pulumi@1
    inputs:
      ...
    env:
      COMMIT_ID: $(Build.SourceVersion)
And then in your Pulumi program, just read the environment variable
COMMIT_ID
and concatenate that to your resource names.
✔️ 1
t
It may be helpful to describe your details in https://github.com/pulumi/pulumi/issues/1518