0

I need to find and replace some variables into configuration files during the build process. I'm using vsts-regex-tasks to do this this. It works fine for user created variables, but when trying to reference Azure defined variables it appears the variable doesn't get evaluated. Any Ideas?

Example
Find: "RELEASE_NAME"
Replace With: "$(Release.ReleaseName)"
Result: "$(Release.ReleaseName)"

Edit:

I was trying to use Release variables in a build pipeline and the plug-in I was using couldn't read any Azure defined variables, switching to 'Replace Tokens' worked like a charm and reduced the number of build steps to replace multiple variables.

Chad
  • 892
  • 2
  • 11
  • 25
  • Hi, how’s the things going? Which method are you using? Does the below solution could help you replace the variable successfully now? If yes, you can accept it thus it could let other SO users know whether it is works. If not, don’t hesitate to leave comment here. Then we could still help you. – Mengdi Liang Oct 13 '19 at 06:40

1 Answers1

1

First, if the method you used to apply the expression with the variable $(Release.ReleaseName) is in YAML, afraid to say that release variables could not be phrased in YAML definition. Though we integrated the release definition into YAML, but actually, its environment is still belong to Build.

See the Note from this doc:

enter image description here

All of these release variables are only available for the Classic release pipeline.

When you are trying to use YAML to define and configure the release pipeline, only the variables that listed in doc can be phrased.

enter image description here


But, if the configure type you used is classic instead of YAML, you should first check the value of Search Paths to Input Files. As normal, this issue can all be checked from log.

Here my project is a Jmeter test project, and its config file is WebservicePerformanceTest.jmx. Now, my sample is replacing one service port name as $(Release.ReleaseName) in this .jmx file.

enter image description here

Below is my local release result, you can see that its succeed to replace the variable.

enter image description here

Additionally, there has another task can also achieve what you want: Replace token. For the detailed steps for usage, you can refer to my previous answer.

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35