'Azure TFS: Setting a Variable Value From File

I am writing an Azure Pipeline with YAML file, and would like to have the name of the pipeline to contain the current version. My question is basically how can I set a variable by reading from a file or from stdout. Something like:

name: $(GradleVersion)
variables:
  GradleVersion: <Get this value from a file or stdout>

More specifically:
The artifact is a Java artifact built with Gradle. Part of the task is to version the artifact: <major>.<minor>.<build>.
This string is available in a file prior to running the pipeline.

Is there a way to add this value into a variable inside the pipeline?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source