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
|
|
@ -40,167 +40,149 @@ stages:
|
||||||
runOnce:
|
runOnce:
|
||||||
deploy:
|
deploy:
|
||||||
steps:
|
steps:
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: Output Deployment Parameters
|
displayName: Output Deployment Parameters
|
||||||
condition: contains(variables['system.debug'], 'true')
|
condition: contains(variables['system.debug'], 'true')
|
||||||
inputs:
|
inputs:
|
||||||
targetType: inline
|
targetType: inline
|
||||||
script: |
|
script: |
|
||||||
Write-Host "DeploymentType: ${{parameters.DeploymentType}}"
|
Write-Host "DeploymentType: ${{parameters.DeploymentType}}"
|
||||||
Write-Host "DependsOn: ${{parameters.DependsOn}}"
|
Write-Host "DependsOn: ${{parameters.DependsOn}}"
|
||||||
Write-Host "ApplicationName: ${{parameters.ApplicationName}}"
|
Write-Host "ApplicationName: ${{parameters.ApplicationName}}"
|
||||||
Write-Host "PublishFolder: ${{parameters.PublishFolder}}"
|
Write-Host "PublishFolder: ${{parameters.PublishFolder}}"
|
||||||
Write-Host "RepositoryFolder: ${{parameters.RepositoryFolder}}"
|
Write-Host "RepositoryFolder: ${{parameters.RepositoryFolder}}"
|
||||||
pwsh: true
|
pwsh: true
|
||||||
|
|
||||||
- template: output-environment-variables.yml@self
|
- template: output-environment-variables.yml@self
|
||||||
|
|
||||||
- checkout: MasterRepo
|
- checkout: MasterRepo
|
||||||
enabled: false
|
enabled: false
|
||||||
persistCredentials: true
|
persistCredentials: true
|
||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: Pull Master Repository Files
|
displayName: Pull Master Repository Files
|
||||||
enabled: false
|
enabled: false
|
||||||
env:
|
env:
|
||||||
DEPLOY_BUILDNUMBER: $(Build.BuildNumber)
|
DEPLOY_BUILDNUMBER: $(Build.BuildNumber)
|
||||||
DEPLOY_SOURCESDIRECTORY: $(Build.SourcesDirectory)
|
DEPLOY_SOURCESDIRECTORY: $(Build.SourcesDirectory)
|
||||||
inputs:
|
inputs:
|
||||||
targetType: inline
|
targetType: inline
|
||||||
script: |
|
script: |
|
||||||
Write-Host "Setting up the global configuration"
|
Write-Host "Setting up the global configuration"
|
||||||
git config --global user.email "${{parameters.GitEmail}}"
|
git config --global user.email "${{parameters.GitEmail}}"
|
||||||
git config --global user.name "${{parameters.GitUsername}}"
|
git config --global user.name "${{parameters.GitUsername}}"
|
||||||
|
|
||||||
Write-Host "Performing Git Checkout"
|
Write-Host "Performing Git Checkout"
|
||||||
git checkout -b master
|
git checkout -b master
|
||||||
|
|
||||||
Write-Host "Performing Git Fetch"
|
Write-Host "Performing Git Fetch"
|
||||||
git fetch
|
git fetch
|
||||||
|
|
||||||
Write-Host "Performing Git Branch"
|
Write-Host "Performing Git Branch"
|
||||||
git branch --set-upstream-to=origin/master master
|
git branch --set-upstream-to=origin/master master
|
||||||
|
|
||||||
Write-Host "Performing Git Pull"
|
Write-Host "Performing Git Pull"
|
||||||
git pull --force
|
git pull --force
|
||||||
pwsh: true
|
pwsh: true
|
||||||
workingDirectory: '$(Build.SourcesDirectory)'
|
workingDirectory: '$(Build.SourcesDirectory)'
|
||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: Copy ${{parameters.DeploymentType}} Files
|
displayName: Copy ${{parameters.DeploymentType}} Files
|
||||||
enabled: false
|
enabled: false
|
||||||
env:
|
env:
|
||||||
DEPLOY_BUILDNUMBER: $(Build.BuildNumber)
|
DEPLOY_BUILDNUMBER: $(Build.BuildNumber)
|
||||||
DEPLOY_PUBLISHDIRECTORY: "$(Agent.BuildDirectory)/${{parameters.PublishFolder}}"
|
DEPLOY_PUBLISHDIRECTORY: "$(Agent.BuildDirectory)/${{parameters.PublishFolder}}"
|
||||||
DEPLOY_REPODIRECTORY: "$(Build.SourcesDirectory)/${{parameters.RepositoryFolder}}"
|
DEPLOY_REPODIRECTORY: "$(Build.SourcesDirectory)/${{parameters.RepositoryFolder}}"
|
||||||
inputs:
|
inputs:
|
||||||
targetType: inline
|
targetType: inline
|
||||||
script: |
|
script: |
|
||||||
$appVersion = $env:DEPLOY_BUILDNUMBER
|
$appVersion = $env:DEPLOY_BUILDNUMBER
|
||||||
$appVersionShort = $appVersion.Substring(0, $appVersion.LastIndexOf('.'))
|
$appVersionShort = $appVersion.Substring(0, $appVersion.LastIndexOf('.'))
|
||||||
|
|
||||||
if (!(Test-Path $env:DEPLOY_PUBLISHDIRECTORY)) {
|
if (!(Test-Path $env:DEPLOY_PUBLISHDIRECTORY)) {
|
||||||
throw "Source directory does not exist or could not be found ($env:DEPLOY_PUBLISHDIRECTORY)"
|
throw "Source directory does not exist or could not be found ($env:DEPLOY_PUBLISHDIRECTORY)"
|
||||||
}
|
}
|
||||||
if (!(Test-Path $env:DEPLOY_REPODIRECTORY)) {
|
if (!(Test-Path $env:DEPLOY_REPODIRECTORY)) {
|
||||||
New-Item -Path "$env:DEPLOY_REPODIRECTORY" -ItemType Directory -Force
|
New-Item -Path "$env:DEPLOY_REPODIRECTORY" -ItemType Directory -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# copy common files
|
# copy common files
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\en-US.xaml" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\en-US.xaml" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latest.zip" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latest.zip" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
|
|
||||||
# copy beta specific files
|
# copy beta specific files
|
||||||
if ('${{parameters.DeploymentType}}' -eq 'Beta') {
|
if ('${{parameters.DeploymentType}}' -eq 'Beta') {
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latestBeta.txt" -Destination "$env:DEPLOY_REPODIRECTORY\latest.txt" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latestBeta.txt" -Destination "$env:DEPLOY_REPODIRECTORY\latest.txt" -Force
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\VersionFeedBeta.xml" -Destination "$env:DEPLOY_REPODIRECTORY\VersionFeed.xml" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\VersionFeedBeta.xml" -Destination "$env:DEPLOY_REPODIRECTORY\VersionFeed.xml" -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# copy production specific files
|
# copy production specific files
|
||||||
if ('${{parameters.DeploymentType}}' -eq 'Production') {
|
if ('${{parameters.DeploymentType}}' -eq 'Production') {
|
||||||
$applicationFilenamePrefix = "${{parameters.ApplicationName}}_$appVersionShort"
|
$applicationFilenamePrefix = "${{parameters.ApplicationName}}_$appVersionShort"
|
||||||
|
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\$applicationFilenamePrefix.exe" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\$applicationFilenamePrefix.exe" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\$applicationFilenamePrefix.zip" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\$applicationFilenamePrefix.zip" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latest.exe" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latest.exe" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latest.txt" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\latest.txt" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\VersionFeed.xml" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
Copy-Item -Path "$env:DEPLOY_PUBLISHDIRECTORY\VersionFeed.xml" -Destination "$env:DEPLOY_REPODIRECTORY" -Force
|
||||||
}
|
}
|
||||||
pwsh: true
|
pwsh: true
|
||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: Commit ${{parameters.DeploymentType}} Files
|
displayName: Commit ${{parameters.DeploymentType}} Files
|
||||||
enabled: false
|
enabled: false
|
||||||
env:
|
env:
|
||||||
DEPLOY_BUILDNUMBER: $(Build.BuildNumber)
|
DEPLOY_BUILDNUMBER: $(Build.BuildNumber)
|
||||||
DEPLOY_SOURCESDIRECTORY: $(Build.SourcesDirectory)
|
DEPLOY_SOURCESDIRECTORY: $(Build.SourcesDirectory)
|
||||||
inputs:
|
inputs:
|
||||||
targetType: inline
|
targetType: inline
|
||||||
script: |
|
script: |
|
||||||
$appVersion = $env:DEPLOY_BUILDNUMBER
|
$appVersion = $env:DEPLOY_BUILDNUMBER
|
||||||
$appVersionShort = $appVersion.Substring(0, $appVersion.LastIndexOf('.'))
|
$appVersionShort = $appVersion.Substring(0, $appVersion.LastIndexOf('.'))
|
||||||
|
|
||||||
Write-Host "Setting up the global configuration"
|
Write-Host "Setting up the global configuration"
|
||||||
git config --global user.email "${{parameters.GitEmail}}"
|
git config --global user.email "${{parameters.GitEmail}}"
|
||||||
git config --global user.name "${{parameters.GitUsername}}"
|
git config --global user.name "${{parameters.GitUsername}}"
|
||||||
|
|
||||||
Write-Host "Performing Git Add"
|
Write-Host "Performing Git Add"
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
Write-Host "Performing Git Commit"
|
Write-Host "Performing Git Commit"
|
||||||
if ('${{parameters.DeploymentType}}' -eq 'Beta') {
|
if ('${{parameters.DeploymentType}}' -eq 'Beta') {
|
||||||
git commit -m "${{parameters.ApplicationName}} Beta $appVersion"
|
git commit -m "${{parameters.ApplicationName}} Beta $appVersion"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('${{parameters.DeploymentType}}' -eq 'Production') {
|
if ('${{parameters.DeploymentType}}' -eq 'Production') {
|
||||||
git commit -m "${{parameters.ApplicationName}} $appVersionShort"
|
git commit -m "${{parameters.ApplicationName}} $appVersionShort"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Performing Git Push"
|
Write-Host "Performing Git Push"
|
||||||
git push --set-upstream origin master --porcelain --force
|
git push --set-upstream origin master --porcelain --force
|
||||||
pwsh: true
|
pwsh: true
|
||||||
workingDirectory: '$(Build.SourcesDirectory)'
|
workingDirectory: '$(Build.SourcesDirectory)'
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: 'Update VersionBuild Variable'
|
|
||||||
condition: eq('${{parameters.DeploymentType}}', 'Production')
|
|
||||||
enabled: false
|
|
||||||
env:
|
|
||||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './.azure/scripts/UpdateVersionVariable.ps1'
|
|
||||||
arguments: "-variableName 'VersionBuild'"
|
|
||||||
pwsh: true
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
- ${{ if eq(parameters.DeploymentType, 'Beta') }}:
|
||||||
displayName: 'Update VersionRevision Variable'
|
- template: update-pipeline-variable.yml@self
|
||||||
condition: eq('${{parameters.DeploymentType}}', 'Beta')
|
|
||||||
enabled: true
|
|
||||||
env:
|
|
||||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './.azure/scripts/UpdateVersionVariable.ps1'
|
|
||||||
pwsh: true
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: 'Reset VersionRevision Variable'
|
|
||||||
condition: eq('${{parameters.DeploymentType}}', 'Production')
|
|
||||||
enabled: false
|
|
||||||
env:
|
|
||||||
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
|
|
||||||
parameters:
|
parameters:
|
||||||
CleanArtifactsFolder: true
|
VariableName: 'VersionRevision'
|
||||||
CleanBinariesFolder: true
|
VariableValue: $(VersionRevision) + 1
|
||||||
CleanSourcesFolder: true
|
|
||||||
CleanPublishFolder: true
|
- ${{ if eq(parameters.DeploymentType, 'Production') }}:
|
||||||
PublishFolder: $(PublishFolder)
|
- template: update-pipeline-variable.yml@self
|
||||||
|
parameters:
|
||||||
|
VariableName: 'VersionBuild'
|
||||||
|
VariableValue: $(VersionBuild) + 1
|
||||||
|
|
||||||
|
- ${{ if eq(parameters.DeploymentType, 'Production') }}:
|
||||||
|
- template: update-pipeline-variable.yml@self
|
||||||
|
parameters:
|
||||||
|
VariableName: 'VersionRevision'
|
||||||
|
VariableValue: 1
|
||||||
|
|
||||||
|
- template: azure-pipelines-clean-agent.yml@self
|
||||||
|
parameters:
|
||||||
|
CleanArtifactsFolder: true
|
||||||
|
CleanBinariesFolder: true
|
||||||
|
CleanSourcesFolder: true
|
||||||
|
CleanPublishFolder: true
|
||||||
|
PublishFolder: $(PublishFolder)
|
||||||
|
|
|
||||||
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