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
6d1da1270f
commit
942fdb66d3
2 changed files with 183 additions and 143 deletions
|
|
@ -161,41 +161,23 @@ stages:
|
||||||
pwsh: true
|
pwsh: true
|
||||||
workingDirectory: '$(Build.SourcesDirectory)'
|
workingDirectory: '$(Build.SourcesDirectory)'
|
||||||
|
|
||||||
- task: PowerShell@2
|
- ${{ if eq(parameters.DeploymentType, 'Beta') }}:
|
||||||
displayName: 'Update VersionBuild Variable'
|
- template: update-pipeline-variable.yml@self
|
||||||
condition: eq('${{parameters.DeploymentType}}', 'Production')
|
parameters:
|
||||||
enabled: false
|
VariableName: 'VersionRevision'
|
||||||
env:
|
VariableValue: $(VersionRevision) + 1
|
||||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './.azure/scripts/UpdateVersionVariable.ps1'
|
|
||||||
arguments: "-variableName 'VersionBuild'"
|
|
||||||
pwsh: true
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
- ${{ if eq(parameters.DeploymentType, 'Production') }}:
|
||||||
displayName: 'Update VersionRevision Variable'
|
- template: update-pipeline-variable.yml@self
|
||||||
condition: eq('${{parameters.DeploymentType}}', 'Beta')
|
parameters:
|
||||||
enabled: true
|
VariableName: 'VersionBuild'
|
||||||
env:
|
VariableValue: $(VersionBuild) + 1
|
||||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './.azure/scripts/UpdateVersionVariable.ps1'
|
|
||||||
pwsh: true
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
- ${{ if eq(parameters.DeploymentType, 'Production') }}:
|
||||||
displayName: 'Reset VersionRevision Variable'
|
- template: update-pipeline-variable.yml@self
|
||||||
condition: eq('${{parameters.DeploymentType}}', 'Production')
|
parameters:
|
||||||
enabled: false
|
VariableName: 'VersionRevision'
|
||||||
env:
|
VariableValue: 1
|
||||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
|
||||||
VERSIONREVISION: 0
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './.azure/scripts/UpdateVersionVariable.ps1'
|
|
||||||
arguments: "-variableName 'VersionRevision'"
|
|
||||||
pwsh: true
|
|
||||||
|
|
||||||
- template: azure-pipelines-clean-agent.yml@self
|
- template: azure-pipelines-clean-agent.yml@self
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
||||||
58
.azure/pipelines/update-pipeline-variable.yml
Normal file
58
.azure/pipelines/update-pipeline-variable.yml
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
parameters:
|
||||||
|
- name: VariableName
|
||||||
|
displayName: Variable Name
|
||||||
|
- name: VariableValue
|
||||||
|
displayName: Variable Value
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: Update Pipeline Variable - ${{parameters.VariableName}}
|
||||||
|
env:
|
||||||
|
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
||||||
|
inputs:
|
||||||
|
targetType: inline
|
||||||
|
script: |
|
||||||
|
[string]$repositoryUrl = $env:SYSTEM_COLLECTIONURI
|
||||||
|
[string]$repositoryName = $env:SYSTEM_TEAMPROJECT
|
||||||
|
[string]$definitionId = $env:SYSTEM_DEFINITIONID
|
||||||
|
[string]$variableName = ${{parameters.VariableName}}
|
||||||
|
[string]$variableValue = ${{parameters.VariableValue}}
|
||||||
|
[string]$accessToken = $env:SYSTEM_ACCESSTOKEN
|
||||||
|
[string]$debugMode = $env.SYSTEM_DEBUG
|
||||||
|
|
||||||
|
if ($debugMode -eq 'true') {
|
||||||
|
Write-Host '##[section]Starting: DEBUG INFORMATION'
|
||||||
|
|
||||||
|
Write-Host "##[debug]repositoryUrl = $repositoryUrl"
|
||||||
|
Write-Host "##[debug]repositoryName = $repositoryName"
|
||||||
|
Write-Host "##[debug]definitionId = $definitionId"
|
||||||
|
Write-Host "##[debug]variableName = $variableName"
|
||||||
|
Write-Host "##[debug]variableValue = $variableValue"
|
||||||
|
|
||||||
|
Write-Host '##[section]Finishing: DEBUG INFORMATION'
|
||||||
|
Write-Host ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if($repositoryUrl.EndsWith('/')) {
|
||||||
|
$repositoryUrl = $repositoryUrl.TrimEnd('/')
|
||||||
|
}
|
||||||
|
|
||||||
|
$headers = @{
|
||||||
|
'Authorization' = "Bearer $accessToken"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get an overview of the build definition
|
||||||
|
$definitionUrl = "$repositoryUrl/$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
|
||||||
|
|
||||||
|
Write-Output -InputObject "Updating $variableName from $($oldValue) to $($variableValue)..."
|
||||||
|
|
||||||
|
$body = ConvertTo-Json -InputObject $definitionResponse -Depth 100 -Compress
|
||||||
|
$response = Invoke-RestMethod -Method Put -Uri $definitionsUrl -Headers $headers -ContentType 'application/json' -Body $body -UseBasicParsing
|
||||||
|
}
|
||||||
|
pwsh: true
|
||||||
Loading…
Add table
Add a link
Reference in a new issue