mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
pipeline file changes
This commit is contained in:
parent
be2730ea23
commit
d394c57a10
2 changed files with 99 additions and 16 deletions
|
|
@ -12,33 +12,35 @@ steps:
|
|||
inputs:
|
||||
targetType: inline
|
||||
script: |
|
||||
[string]$repositoryUrl = $env:SYSTEM_COLLECTIONURI
|
||||
[string]$repositoryName = $env:SYSTEM_TEAMPROJECT
|
||||
[string]$definitionId = $env:SYSTEM_DEFINITIONID
|
||||
[string]$CollectionUri = $env:SYSTEM_COLLECTIONURI
|
||||
[string]$ProjectName = $env:SYSTEM_TEAMPROJECT
|
||||
[string]$DefinitionId = $env:SYSTEM_DEFINITIONID
|
||||
[string]$variableName = '${{parameters.VariableName}}'
|
||||
[string]$variableValue = '${{parameters.VariableValue}}'
|
||||
[string]$accessToken = $env:SYSTEM_ACCESSTOKEN
|
||||
|
||||
if ($repositoryUrl.EndsWith('/')) {
|
||||
$repositoryUrl = $repositoryUrl.TrimEnd('/')
|
||||
if ($CollectionUri.EndsWith('/')) {
|
||||
$CollectionUri = $CollectionUri.TrimEnd('/')
|
||||
}
|
||||
|
||||
$headers = @{
|
||||
'Authorization' = "Bearer $accessToken"
|
||||
'Authorization' = "Bearer $AccessToken"
|
||||
}
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = "Tls12, Tls13"
|
||||
|
||||
# Get an overview of the build definition
|
||||
$definitionUrl = "$repositoryUrl/$repositoryName/_apis/build/Definitions/$($definitionId)?api-version=5.0"
|
||||
$definitionUrl = "$CollectionUri/$repositoryName/_apis/build/Definitions/$($definitionId)?api-version=5.0"
|
||||
$definitionResponse = Invoke-RestMethod -Method Get -Uri $definitionUrl -Headers $headers -UseBasicParsing
|
||||
|
||||
# If the build has the variable, update it.
|
||||
if ($definitionResponse.variables.$variableName) {
|
||||
$oldValue = $definitionResponse.variables.$variableName.value
|
||||
$definitionResponse.variables.$variableName.value = $variableValue
|
||||
if ($definitionResponse.variables.$VariableName) {
|
||||
$oldValue = $definitionResponse.variables.$variableName.value
|
||||
$definitionResponse.variables.$variableName.value = $VariableValue
|
||||
|
||||
Write-Output -InputObject "Updating $variableName from $($oldValue) to $($variableValue)..."
|
||||
Write-Output -InputObject "Updating $variableName from $($oldValue) to $($variableValue)..."
|
||||
|
||||
$body = ConvertTo-Json -InputObject $definitionResponse -Depth 100 -Compress
|
||||
$response = Invoke-RestMethod -Method Put -Uri $definitionUrl -Headers $headers -ContentType 'application/json' -Body $body -UseBasicParsing
|
||||
$body = ConvertTo-Json -InputObject $definitionResponse -Depth 100 -Compress
|
||||
$response = Invoke-RestMethod -Method Put -Uri $definitionUrl -Headers $headers -ContentType 'application/json' -Body $body -UseBasicParsing
|
||||
}
|
||||
pwsh: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue