$projectName = “Testing testing 123”
$project = $repository.Projects.FindByName($projectName);
if (!$project) {
Write-Host(“Failed to find project with name $($projectName).”)
Exit
}
$releaseVersion = “0.0.2”
$release = $repository.Projects.GetReleaseByVersion($project, $releaseVersion);
if (!$release) {
Write-Host(“Failed to find release with version $($releaseVersion).”)
Exit
}
Unfortunately, the update snapshot function is all or nothing. The only way I can think of achieving what you want would be to have a script that changes that single variable to the value you want, then running the update variable snapshot script, then amending the variable back to what it was.
I want achieve to keep that specific project variable unchanged even after “Update variable” , so for that i need a script to get the project variable (Which i want to exclude from Update variables , i.e old value before updating snap shoot) and amending back after “Update variable”.
I would need to have a better understanding of what your use case if for this scenario first.
It sounds like you’re updating a bunch of project variables, then want to update a release with these variable changes, except for the change to variable ‘check’.
This isn’t possible in single script.
The only way I could see to achieve this would be to break it down into two stages.
In the first stage, you amend all of the project variables that you need to change, except for variable ‘check’. You then run the variable snapshot script for your release.
It now has all variable changes applied except for ‘check’.
Stage two would be to then amend the variable ‘check’ to whatever value you want it to be, but without running the variable snapshot script.
What I don’t really understand is why you’re needing to do this in the first place?
Is this a one-off run to fix some variables in a specific release or is this part of your regular deployment process?
If you need different releases to have different values for the variable ‘check’ as ongoing situation, then perhaps it may be easier to apply some form of scoping to this variable, maybe making use of release channels or environments to separate when the different ‘check’ values are applied.
Thanks for your help ,
I understand that it need 2 phase to achieve , Do you have any sample powershell scripts to ( ""amend all of the project variables that you need to change, except for variable ‘check’ “”. and ““Stage two would be to then amend the variable ‘check’ to whatever value you want it to be, but without running the variable snapshot script.”” ) serve the same so that i can modify as per my request .