-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e19d2a8
commit 45b89c0
Showing
36 changed files
with
1,235 additions
and
796 deletions.
There are no files selected for viewing
172 changes: 101 additions & 71 deletions
172
.azuredevops/azureDevOpsScaleSet/.templates/pipeline.scaleset.jobs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,113 @@ | ||
parameters: | ||
- name: environment | ||
default: | ||
- name: deploymentsToPerform | ||
default: | ||
- name: serviceConnection | ||
default: | ||
- name: waitForscalesetBuild | ||
default: | ||
- name: environment | ||
default: | ||
- name: deploymentsToPerform | ||
default: | ||
- name: serviceConnection | ||
default: | ||
- name: waitForscalesetBuild | ||
default: | ||
- name: setAgentPool | ||
default: | ||
|
||
jobs: | ||
- deployment: deploy_job | ||
displayName: Deploy Resources | ||
environment: ${{ parameters.environment }} | ||
timeoutInMinutes: 120 | ||
pool: | ||
vmImage: '$(vmImage_${{ parameters.environment }})' | ||
name: '$(poolName_${{ parameters.environment }})' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: self | ||
# [Deployment] task(s) | ||
#--------------------- | ||
- task: AzurePowerShell@4 | ||
displayName: 'Deploy [scaleset.deploy.bicep] via service connection [$(serviceConnection_${{ parameters.environment }})]' | ||
name: deploy_task | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
# Load used functions | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'New-ModuleDeployment.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Test-TemplateWithParameterFile.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Set-CustomParameter') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Select-Image.ps1') | ||
- deployment: deploy_job | ||
displayName: Deploy Resources | ||
environment: ${{ parameters.environment }} | ||
timeoutInMinutes: 120 | ||
pool: | ||
vmImage: '$(vmImage_${{ parameters.environment }})' | ||
name: '$(poolName_${{ parameters.environment }})' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- checkout: self | ||
# [Deployment] task(s) | ||
#--------------------- | ||
- task: AzurePowerShell@4 | ||
displayName: 'Deploy [scaleset.deploy.bicep] via service connection [$(serviceConnection_${{ parameters.environment }})]' | ||
name: deploy_task | ||
inputs: | ||
azureSubscription: '$(serviceConnection_${{ parameters.environment }})' | ||
ScriptType: InlineScript | ||
inline: | | ||
# Load used functions | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'New-ModuleDeployment.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Test-TemplateWithParameterFile.ps1') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(sharedOrchestrationFunctionsPath)' 'deployment' 'Set-CustomParameter') | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Select-Image.ps1') | ||
# Check the provide image | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.scaleset.parameters.json' | ||
$parameterFileContent = ConvertFrom-Json (Get-Content $parameterFilePath -Raw) -AsHashTable | ||
if($imageVersionReference = Select-Image -imageReference $parameterFileContent.parameters.vmssParam.value.imageReference -Verbose) { | ||
$customValueMap += @{ | ||
path = 'vmssParam.value.imageReference.id' | ||
value = $imageVersionReference | ||
} | ||
} | ||
# Check the provide image | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.scaleset.parameters.json' | ||
$parameterFileContent = ConvertFrom-Json (Get-Content $parameterFilePath -Raw) -AsHashTable | ||
# Overwrite parameter file if necessary | ||
if($customValueMap.Count -gt 0) { | ||
$overwriteInputObject = @{ | ||
if($imageVersionReference = Select-Image -imageReference $parameterFileContent.parameters.vmssParam.value.imageReference -Verbose) { | ||
$customValueMap += @{ | ||
path = 'vmssParam.value.imageReference.id' | ||
value = $imageVersionReference | ||
} | ||
} | ||
# Overwrite parameter file if necessary | ||
if($customValueMap.Count -gt 0) { | ||
$overwriteInputObject = @{ | ||
parameterFilePath = $parameterFilePath | ||
valueMap = $customValueMap | ||
} | ||
Set-CustomParameter @overwriteInputObject | ||
} | ||
# ----------------- # | ||
# INVOKE DEPLOYMENT # | ||
# ----------------- # | ||
$functionInput = @{ | ||
templateFilePath = Join-Path '$(templatesPath)' 'scaleset.deploy.bicep' | ||
parameterFilePath = $parameterFilePath | ||
valueMap = $customValueMap | ||
location = '$(location)' | ||
subscriptionId = (Get-AzContext).Subscription.Id | ||
} | ||
Set-CustomParameter @overwriteInputObject | ||
} | ||
# ----------------- # | ||
# INVOKE DEPLOYMENT # | ||
# ----------------- # | ||
$functionInput = @{ | ||
templateFilePath = Join-Path '$(templatesPath)' 'scaleset.deploy.bicep' | ||
parameterFilePath = $parameterFilePath | ||
location = '$(location)' | ||
subscriptionId = (Get-AzContext).Subscription.Id | ||
} | ||
# Inject control parmaeters from pipeline | ||
$functionInput['additionalParameters'] = @{ | ||
deploymentsToPerform = '${{ parameters.deploymentsToPerform }}' | ||
} | ||
# Inject control parmaeters from pipeline | ||
$functionInput['additionalParameters'] = @{ | ||
deploymentsToPerform = '${{ parameters.deploymentsToPerform }}' | ||
} | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
# Validate deployment | ||
Test-TemplateWithParameterFile @functionInput | ||
# Invoke deployment | ||
New-ModuleDeployment @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion | ||
- task: PowerShell@2 | ||
displayName: Register scale set | ||
condition: | | ||
and( | ||
succeeded(), | ||
eq('${{ parameters.setAgentPool }}', 'true') | ||
) | ||
inputs: | ||
targetType: inline | ||
pwsh: true | ||
script: | | ||
# Load used functions | ||
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'registerScaleSet' 'Register-ElasticPool.ps1') | ||
$parameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.agentpool.parameters.json' | ||
$parameterFileContent = ConvertFrom-Json (Get-Content $parameterFilePath -Raw) -AsHashTable | ||
$inputObject = @{ | ||
Organization = $parameterFileContent.Organization | ||
Project = $parameterFileContent.Project | ||
ServiceConnectionName = $parameterFileContent.ServiceConnectionName | ||
AgentPoolProperties = $parameterFileContent.AgentPoolProperties | ||
} | ||
# Validate deployment | ||
Test-TemplateWithParameterFile @functionInput | ||
Write-Verbose "Invoke task with" -Verbose | ||
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
# Invoke deployment | ||
New-ModuleDeployment @functionInput -Verbose | ||
errorActionPreference: stop | ||
azurePowerShellVersion: LatestVersion | ||
Sync-ElasticPool @inputObject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,54 @@ | ||
name: 'ScaleSet Deployment' | ||
|
||
parameters: | ||
- name: startEnvironment | ||
displayName: Environment to start from | ||
type: string | ||
default: sbx | ||
values: | ||
- sbx | ||
- dev | ||
- prd | ||
- name: deploymentsToPerform | ||
displayName: Scope of deployment | ||
type: string | ||
default: Only Scale Set | ||
values: | ||
- All | ||
- Only Scale Set | ||
- name: startEnvironment | ||
displayName: Environment to start from | ||
type: string | ||
default: sbx | ||
values: | ||
- sbx | ||
- dev | ||
- prd | ||
- name: deploymentsToPerform | ||
displayName: Scope of deployment | ||
type: string | ||
default: Only Scale Set | ||
values: | ||
- All | ||
- Only Scale Set | ||
- name: setAgentPool | ||
displayName: Add/Update agent pool | ||
type: boolean | ||
default: true | ||
variables: | ||
- template: variables.yml | ||
- template: variables.yml | ||
|
||
trigger: none | ||
|
||
stages: | ||
- stage: SBX_Deployments | ||
displayName: Deploy to SBX | ||
condition: and(succeeded(), eq('${{ parameters.startEnvironment }}', 'sbx')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'sbx' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
- stage: SBX_Deployments | ||
displayName: Deploy to SBX | ||
condition: and(succeeded(), eq('${{ parameters.startEnvironment }}', 'sbx')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'sbx' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
|
||
- stage: DEV_Deployments | ||
displayName: Deploy to DEV | ||
condition: and(succeeded(), in('${{ parameters.startEnvironment }}', 'sbx', 'dev')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'dev' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
- stage: DEV_Deployments | ||
displayName: Deploy to DEV | ||
condition: and(succeeded(), in('${{ parameters.startEnvironment }}', 'sbx', 'dev')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'dev' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
|
||
- stage: PRD_Deployments | ||
displayName: Deploy to PRD | ||
condition: and(succeeded(),in('${{ parameters.startEnvironment }}', 'sbx', 'dev', 'prd')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'prd' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' | ||
- stage: PRD_Deployments | ||
displayName: Deploy to PRD | ||
condition: and(succeeded(),in('${{ parameters.startEnvironment }}', 'sbx', 'dev', 'prd')) | ||
jobs: | ||
- template: .templates/pipeline.scaleset.jobs.yml | ||
parameters: | ||
environment: 'prd' | ||
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.