In the Release Pipeline under Release Notes, I am passing $(Build.SourceVersionMessage) but in my app center I am getting "$(Build.SourceVersionMessage)" as a string instead of the actual value. This variable works in my build pipeline under -task. How can I use this variable or any alternative way to fetch the commit message in the Release pipeline.
-
Are you referring to the [Classic Release pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/release/?view=azure-devops)? What type of artifact is used as input? – danielorn Mar 28 '22 at 10:26
-
Try to set a variable on the release pipeline with the value of `$(Build.SourceVersionMessage)` for example `VersionMessage` and use this on your release pipeline as `$(VersionMessage)` – GeralexGR Mar 28 '22 at 10:29
-
@danielorn Yes I am using Classic Release Pipeline and my Build Pipeline was created by Yaml. It's a Xamarin Forms application so my artifacts have (ios, android, uwp binaries). – Nambukarthy Mar 28 '22 at 10:40
-
@GeralexGR You mean to say that I need to create a variable "VersionMessage" in the release pipeline and set a value like "First commit" is it? If this is what you said then it will work but with every release I need to change the value of my variable(commit message) manually, which I don't want to do. – Nambukarthy Mar 28 '22 at 10:46
-
You should create a variable on the release pipeline with every name you want for example `VersionMessage` and set this variable value `$(Build.SourceVersionMessage)` . Then you can use on the release pipeline the `$(VersionMessage)` variable – GeralexGR Mar 28 '22 at 10:47
-
@GeralexGR Release Pipeline variable Name **VersionMessage** and its value **$(Build.SourceVersionMessage)** and I referred in my release notes **$(VersionMessage)** but still, I can't able to fetch the value of Build.SourceVersionMessage is still as a string "$(Build.SourceVersionMessage)" in the app center. – Nambukarthy Mar 28 '22 at 10:58
-
@Nambukarthy is the release pipeline connected with the build pipeline with a CI/CD ? – GeralexGR Mar 28 '22 at 11:01
-
@GeralexGR yeah, it is connected. In fact, I could able to get the value of $(Build.SourceVersion) variable also. It's only $(Build.SourceVersionMessage) variable's value I couldn't get. Also, my deployment task works fine and it could able to get the artifacts of ios, android, and uwp properly and successfully deploy in the app center. – Nambukarthy Mar 28 '22 at 11:12
-
1Another approach is to write `$(Build.SourceVersionMessage)` on a text file and use this text file and parse the value on the release pipeline, as it is not passed from build to release pipeline – GeralexGR Mar 28 '22 at 11:27
1 Answers
How to get the value of $(Build.SourceVersionMessage) variable in Release Pipeline?
As we know the value of predefined variable $(Build.SourceVersionMessage) is the build pipeline, we could not get it from release pipeline directly.
To resolve this issue, there are three ways to do it:
Just as GeralexGR comment, writing
$(Build.SourceVersionMessage)
on a text file and publish this text file as artifact and parse the value in the release pipeline.Using the REST API Definitions - Update to update the variable with the value of
$(Build.SourceVersionMessage)
in the build pipeline. Or using az pipelines variable-group variable to update the referenced variable group.You could check my previous thread for some more details.
You could combine your classic release pipeline and build YAML pipeline to one pipeline with multiple stages, then we could use output variables from tasks:
dependencies.JOB.outputs['TASK.VARIABLE']

- 71,098
- 10
- 114
- 135