问题
I have a variable called some_var
in an Azure DevOps release pipeline. I'd like to set the default at release time. But I want to set it programmatically based on the contents of a file in the artifact drop folder. But I still want the user to be able to overwrite the dynamically set value at the time they're creating the release.
So the end-user behavior would be that they (1) navigate to the Release and (2) click "Create New". The dialog comes up with the some_var
variable already set to a value stored in a text file. But, because the variable is set to be settable at runtime, they can also modify the variable value before they click the button to create the release.
Is there any way I can dynamically populate (before the release is created) the some_var
value and still make it editable by the person creating the release at crate-time.
回答1:
The dialog comes up with the some_var variable already set to a value stored in a text file.
We don't support this out-of-box feature. The release pipeline variable can't dynamically
populate the some_var
value before the release is created.
Possible workaround:
Your original purpose is to set it programmatically based on the contents of a file in the artifact drop folder
. So I assume you may have a build pipeline which this release depends on, and your actual need is to:
Once the build pipeline is finished, the default value of some_var
in release pipeline should set as the value from build pipeline.
You can consider adding a powershell task in the end of build pipeline that release depends on, calling the Definitions-Update rest api in ps script to set the default value of some_var
in Release pipeline depending on content of Build pipeline. Similar issue you can check this one.
And if the pipeline variable some_var is settable at release time:
The whole behavior would be (assuming we want to pass the buildID in Build to the some_var
in Release):
1.The build pipeline executes well, its last Powershell task updates the some_var
to some_var = 15
.
2.When I click the Create release
button, the dialog comes up with some_var
variable already set to a value from Build pipeline 15
.
3.Now, because the some_var
enables settable at release time, we can easily modify it before clicking the Create
button.
Hope it helps :)
来源:https://stackoverflow.com/questions/61604205/can-i-programmatically-set-an-overridable-default-value-for-a-variable-in-an-azu