I want to pass the PowerShell variable values via azure pipeline variables. Below script is to remove old images from azure container registry. I don't want to pass the values directly as I mentioned in code, those values I need to pass via pipeline variables. I have tried something like this as shown in image highlighted in yellow color. I'm getting error.
Azure pipeline task like AZ CLI as shown in below I'm Getting error like as shown in below
Anyone can help me out this. Thanks in advance....
CodePudding user response:
You must define the variables outside of your scriptblock, below it is a section called Environment Variables, you can store them there like so:
Then you can call them up in the scriptblock as environment variable: $env:LocalDbDataSource
Also, did you mean to put the $
signs in the Pipeline variables table?
As far as I'm aware they are not needed, you should just put the name of your variable.
Another good tip would be to put your variables in a variable group, that way you can centralize where you store the variables. You can add them in the Library section of the pipelines tab
CodePudding user response:
Earlier I have passed same variable name in both cases like PowerShell variable name and Pipeline variables, post changing the name in azure pipeline variables it's working as excepted.