PowerShell에서 Azure 릴리스 변수 값 업데이트
릴리스 변수 $ (ecomm) = Yes, Azure Release Pipeline에 있습니다.

Powershell을 통해 $ (ecomm) = No의 값을 업데이트하고 싶습니다.
Write-Host "Before update: "$(ecomm) Write-Host "##vso[task.setvariable variable=ecomm;]No" Write-Host "After update: "$(ecomm)
그러나 값은 업데이트되지 않습니다. 제발 도와 주 시겠어요? 미리 감사드립니다.
답변
Repcak이 정확합니다.
로깅 명령을 사용하여 Powershell에서 변수를 설정하는 경우 릴리스 정의 대신 파이프 라인 실행에서 변수 값만 변경할 수 있습니다.
Powershell 작업에서 릴리스 정의를 업데이트하려면 다음 파이프 라인 설정을 시도 할 수 있습니다.
두 개의 Powershell 작업을 추가합니다.
1. 첫 번째 PowerShell 작업은 다음 스크립트를 실행합니다.
Write-Host "##vso[task.setvariable variable=ecomm;]No"
이 스크립트는 파이프 라인 실행에서 변수 값을 업데이트하는 데 사용됩니다.
2. 두 번째 Powershell 작업은 다음 스크립트를 실행합니다.
$url = "$($env:SYSTEM_TEAMFOUNDATIONSERVERURI)$env:SYSTEM_TEAMPROJECTID/_apis/Release/definitions/$($env:RELEASE_DEFINITIONID)?api-version=5.0-preview.3"
Write-Host "URL: $url" $pipeline = Invoke-RestMethod -Uri $url -Headers @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 100)"
$pipeline.variables.ecomm.value = "$(ecomm)"
$json = @($pipeline) | ConvertTo-Json -Depth 99
$updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
참고 : 일부 릴리스 옵션도 설정해야합니다.
옵션을 선택 :
Allow scripts to access the OAuth token
에Releases -> Agent Job
Edit release pipeline
역할에 대한 권한 부여 :Project Collection Build Service (OrgName)
결과:

자세한 내용은 이 티켓을 참조하세요 .
수행하는 방식에 따라 주어진 파이프 라인 실행에 대한 변수 만 업데이트합니다. Azure Pipelines는 표시되는 인터페이스에서 이러한 변수를 가져온 다음이를 재정의 할 수 있습니다 (가져온 변수의 인스턴스). 클래식 인터페이스에서 변수를 변경하려면 AzureDevops에 대한 API 호출을 만들어야합니다.