Interface IVariableService
Defines a centralized service for managing workflow variables, coordinating operations across multiple providers.
public interface IVariableService
Remarks
This service abstracts the complexity of multiple variable providers, offering a unified API for reading and writing variables. It delegates operations to registered IVariableProvider implementations, trying custom providers first before falling back to the base Atom provider.
Methods
ReadVariable(string, string, CancellationToken)
Reads a variable written by a specific job.
Task<string?> ReadVariable(string jobName, string variableName, CancellationToken cancellationToken = default)
Parameters
jobNamestringThe name of the job context from which to read the variable.
variableNamestringThe name of the variable as defined in the build parameters.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<string>
The variable's value, or
nullif no provider could supply it.
Remarks
A value that is found is also exposed as an environment variable named after the parameter's argument name, so that it resolves through IParamService like any other parameter.
WriteVariable(string, string, CancellationToken)
Writes a variable to the workflow context, making it available for subsequent steps and jobs.
Task WriteVariable(string variableName, string variableValue, CancellationToken cancellationToken = default)
Parameters
variableNamestringThe name of the variable as defined in the build parameters.
variableValuestringThe value to store for the variable.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task
A System.Threading.Tasks.Task representing the asynchronous write operation.
Remarks
The service resolves the variable's argument name from the build definition and attempts to write it using custom providers first. If none succeed, it uses the base Atom provider.