Skip to content

Commit

Permalink
feat: Add build and deploy YAML pipelines (#125)
Browse files Browse the repository at this point in the history
* add yaml pipelines for framework

* add yaml pipelines for dashboard

Co-authored-by: Pim Simons <pim.simons@codit.eu>
  • Loading branch information
pim-simons and Pim Simons committed Jun 14, 2022
1 parent c5456bc commit b864d64
Show file tree
Hide file tree
Showing 12 changed files with 504 additions and 15 deletions.
20 changes: 16 additions & 4 deletions dashboard/installation/dashboard-buildpipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ The pipeline will use variables stored in a variable group, so before creating t

Create a variable group named {prefix}.Invictus.Installation and add these variables:

- **Invictus.Installation.StorageAccount&#46;Name**: invictusreleases
- **Invictus.Installation.StorageAccount.Name**: invictusreleases
- **Invictus.Installation.StorageAccount.Dashboard.SasToken**: value provided by Codit Software
- **Invictus.Installation.StorageAccount.Framework.SasToken**: value provided by Codit Software

Once you have the variable group, we can now proceed to creating the build pipeline.

## Create the build pipeline
## YAML Pipeline
Add the files and folders from [this](./pipelines) location to your DevOps repo.
This contains an example YAML pipelines to build the Invictus for Azure Dashboard, change the [dashboard.build.yaml](./pipelines/dashboard.build.yaml) file according to your needs, for example change the trigger path:
``` yaml
paths:
include:
- /src/customer.azure.invictus
```

Afterwards add the [dashboard.build.yaml](./pipelines/dashboard.build.yaml) in your DevOps environment as a pipeline, once you've saved the build pipeline you can create the [release pipeline](dashboard-releasepipeline.md).

## Classic Pipeline
### Create the build pipeline

Create a new build pipeline, starting with an empty template with this naming: {prefix}.Invictus.Dashboard.

Expand All @@ -31,7 +43,7 @@ The build will have only 2 tasks:
- A powershell task to pull the resources from blob
- A publish artifacts task

### Powershell task
#### Powershell task

Add a PowerShell task to the pipeline and name it **Pull Dashboard**, then point the script path to the powershell you downloaded at the beginning of this guide.

Expand All @@ -50,7 +62,7 @@ or configure it with these:
- **SaveLocation** (mandatory): `$(build.artifactstagingdirectory)`
- **UseBeta** (optional): by default this is false and will look for the resources in the prod folder, when set to true it will use the resources from the staging folder.

### Publish Artifacts task
#### Publish Artifacts task

Add a Publish build artifacts task to the pipeline and name it **Publish Dashboard**, use `$(Build.ArtifactStagingDirectory)` as the path to publish (or the SaveLocation argument you specified in the previous task).

Expand Down
30 changes: 26 additions & 4 deletions dashboard/installation/dashboard-releasepipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,27 @@ Make sure the Project Collection Build Service has Administrator access to these

> ![Library Security](../../images/ifa-library-security.png)
## Release
## YAML Pipeline
Add the files and folders from [this](./pipelines) location to your DevOps repo.
This contains an example YAML pipeline to release the Invictus for Azure Dashboard, change the [framework.release.yaml](./pipelines/dashboard.release.yaml) file according to your needs, for example change the needed environments and change the name of the build pipeline trigger:
``` yaml
resources:
pipelines:
# Name of the pipeline resource inside this workflow. Used to reference the pipeline resources later on (e.g. download artifacts).
- pipeline: _build
# Name of the pipeline in Azure Pipelines
source: 'customer.azure.invictus.dashboard.build'
trigger: true
```

Also make sure to change the ARM template parameters. In these example files we are deploying to DEV, TST and ADD using a `B1` service plan SKU and a `P1V2` service plan SKU to PRD. Make sure to change and parameterize this according to your needs.

If you need to overwrite more ARM Template parameters make sure to add this to the `deployScriptParameters`. A complete list of ARM Template parameters can be found [here](#ARM-Template-Parameters).

Afterwards add the [framework.release.yaml](./pipelines/dashboard.release.yaml) in your DevOps environment as a pipeline.

## Classic Pipeline
### Release

Create a new release pipeline, starting with an empty template, with this naming: `{prefix}.Invictus.Dashboard`.

Expand All @@ -26,7 +46,7 @@ Add a variable **ArtifactsPath** to the release with scope 'Release' and a value

Please Note that a current bug in the Az library might cause the release to fail for new installation. Simply re-deploy the failed release to resolve the issue.

### Stages
#### Stages

Add a stage for each environment you wish to release to.

Expand Down Expand Up @@ -77,9 +97,11 @@ Complete example of the arguments (note the use of -devOpsObjectId as an additio
-ArtifactsPath "$(ArtifactsPath)" -ResourcePrefix "$(Infra.Environment.ResourcePrefix)" -ResourceGroupName "$(Infra.Environment.ResourceGroup)" -VariableGroupName "Software.Infra.$(Infra.Environment.ShortName)" -ResourceGroupLocation "$(Infra.Environment.Region.Primary)" -devOpsObjectId $(Infra.DevOps.Object.Id)
```

A complete list of ARM Template parameters can be found [here](#ARM-Template-Parameters).

## Azure Active Directory

If you are planning to enable AAD for the dashboard you will need to set the following parameters as **arguments** within the **Deploy Powershell Task**
If you are planning to enable AAD for the dashboard you will need to set the following parameters as **arguments**:

* AzureActiveDirectoryClientId
* AzureActiveDirectoryTenantId
Expand All @@ -89,7 +111,7 @@ The option to login with AAD in the dashboard will only be possible if the above

## Enable Sql Serverless

To deploy the Dashboard database(coditcip) as Sql Servleress simply pass the value for the following paramter "isDashboardDatabaseServerless" as 1. The following parameters can be passed to the deployment but have default values set.
To deploy the Dashboard database(coditcip) as Sql Servleress simply pass the value for the following parameter `isDashboardDatabaseServerless` as 1. The following parameters can be passed to the deployment but have default values set.

* dashboardServerlessDatabaseMaxVCores
* dashboardServerlessDatabaseSize
Expand Down
24 changes: 24 additions & 0 deletions dashboard/installation/pipelines/Templates/build-steps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
parameters:
type: ''
useBeta: ''
storageAccountName: ''
storageSasToken: ''

steps:
- task: PowerShell@2
displayName: 'Pull Sources'
inputs:
targetType: filePath
filePath: './deploy/Invictus-GetSources.ps1'
arguments: '-StorageAccountName "${{parameters.storageAccountName}}" -StorageSasToken "${{parameters.storageSasToken}}" -StorageContainerName "${{parameters.type}}" -SaveLocation "$(Build.ArtifactStagingDirectory)" -UseBeta ${{parameters.useBeta}}'

- task: PublishPipelineArtifact@1
inputs:
TargetPath: $(Build.ArtifactStagingDirectory)
ArtifactName: ${{parameters.type}}
publishLocation: 'pipeline'

- task: PublishPipelineArtifact@1
inputs:
TargetPath: deploy
ArtifactName: scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
azureSubscription: ''
deployScriptParameters: ''
scriptPath: ''

steps:
- task: AzurePowerShell@4
displayName: 'Azure PowerShell'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
azureSubscription: '${{parameters.azureSubscription}}'
ScriptPath: '${{parameters.scriptPath}}'
ScriptArguments: '${{parameters.deployScriptParameters}}'
azurePowerShellVersion: 2.6.0
pwsh: true
53 changes: 53 additions & 0 deletions dashboard/installation/pipelines/dashboard.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ${{ parameters.major }}.${{ parameters.minor }}.${{ parameters.patch }}$(rev:.r)

pr: none
trigger:
branches:
include:
- main
- feature/*
paths:
include:
- /src/customer.azure.invictus

parameters:
- name: major
displayName: Major Version
type: string
default: 4
- name: minor
displayName: Minor Version
type: string
default: 15
- name: patch
displayName: Patch Version
type: string
default: 10
- name: useBeta
displayName: Use Beta
type: string
default: $False

pool:
vmImage: 'windows-latest'

stages:
- stage: Package
displayName: Package
dependsOn: []
variables:
- group: invictus.installation
jobs:
- job: publish
displayName: Build and Publish Dashboard
steps:
- checkout: self
clean: true
persistCredentials: true

- template: ./Templates/build-steps.yaml
parameters:
type: 'dashboard'
useBeta: '${{ parameters.useBeta }}'
storageAccountName: '$(Invictus.Installation.StorageAccount.Name)'
storageSasToken: '$(Invictus.Installation.StorageAccount.Dashboard.SasToken)'
118 changes: 118 additions & 0 deletions dashboard/installation/pipelines/dashboard.release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: $(Rev:r) # This is not used since we define it during the first stage

pr: none

trigger: none

resources:
pipelines:
# Name of the pipeline resource inside this workflow. Used to reference the pipeline resources later on (e.g. download artifacts).
- pipeline: _build
# Name of the pipeline in Azure Pipelines
source: 'customer.azure.invictus.dashboard.build'
trigger: true

variables:
- name: Pipeline.Version
value: $(resources.pipeline._build.runName)

pool:
vmImage: 'windows-latest'

stages:
- stage: preparation
displayName: 'Prepare Deployment'
jobs:
- job: version
displayName: Determine Version
steps:
- powershell: |
$dateTime = $(Get-Date -format yyyyMMddHmmss)
Write-Host "##vso[build.updatebuildnumber]$(Pipeline.Version)-$dateTime"
Write-Host "Pipeline version is '$(Pipeline.Version)-$dateTime'"
displayName: 'Change pipeline version'
- stage: deploy_dev
displayName: 'Deploy to Development'
dependsOn: preparation
variables:
- group: infra.dev
- group: invictus.dev
jobs:
- deployment: deploy_development
displayName: 'Deploy to Development'
environment: Development
strategy:
runOnce:
deploy:
steps:
- download: '_build'
displayName: Download Artifact
- template: ./Templates/dashboard-release-steps.yaml
parameters:
azureSubscription: $(Infra.Environment.ServiceConnection)
scriptPath: '$(Pipeline.Workspace)/_build/dashboard/Deploy.ps1'
deployScriptParameters: '-resourcePrefix $(Infra.Environment.ResourcePrefix) -ArtifactsPath $(Pipeline.Workspace)/_build/dashboard -ResourceGroupName $(Infra.Environment.CustomerPrefix)-$(Infra.Environment.ShortName)-invictus -VariableGroupName invictus.$(Infra.Environment.ShortName) -devOpsObjectId "$(Infra.DevOps.Object.Id)" -servicePlanSkuName "B1" -eventHubSkuName "Standard" -eventHubSkuTier "Standard" -enableStatisticsFunction "true"'
- stage: deploy_tst
displayName: 'Deploy to Test'
dependsOn: deploy_dev
variables:
- group: infra.tst
- group: invictus.tst
jobs:
- deployment: deploy_tst
displayName: 'Deploy to Test'
environment: Test
strategy:
runOnce:
deploy:
steps:
- download: '_build'
displayName: Download Artifact
- template: ./Templates/dashboard-release-steps.yaml
parameters:
azureSubscription: $(Infra.Environment.ServiceConnection)
scriptPath: '$(Pipeline.Workspace)/_build/dashboard/Deploy.ps1'
deployScriptParameters: '-resourcePrefix $(Infra.Environment.ResourcePrefix) -ArtifactsPath $(Pipeline.Workspace)/_build/dashboard -ResourceGroupName $(Infra.Environment.CustomerPrefix)-$(Infra.Environment.ShortName)-invictus -VariableGroupName invictus.$(Infra.Environment.ShortName) -devOpsObjectId "$(Infra.DevOps.Object.Id)" -servicePlanSkuName "B1" -eventHubSkuName "Standard" -eventHubSkuTier "Standard" -enableStatisticsFunction "true"'

- stage: deploy_acc
displayName: 'Deploy to Acceptance'
dependsOn: deploy_tst
variables:
- group: infra.acc
- group: invictus.acc
jobs:
- deployment: deploy_acc
displayName: 'Deploy to Acceptance'
environment: Acceptance
strategy:
runOnce:
deploy:
steps:
- download: '_build'
displayName: Download Artifact
- template: ./Templates/dashboard-release-steps.yaml
parameters:
azureSubscription: $(Infra.Environment.ServiceConnection)
scriptPath: '$(Pipeline.Workspace)/_build/dashboard/Deploy.ps1'
deployScriptParameters: '-resourcePrefix $(Infra.Environment.ResourcePrefix) -ArtifactsPath $(Pipeline.Workspace)/_build/dashboard -ResourceGroupName $(Infra.Environment.CustomerPrefix)-$(Infra.Environment.ShortName)-invictus -VariableGroupName invictus.$(Infra.Environment.ShortName) -devOpsObjectId "$(Infra.DevOps.Object.Id)" -servicePlanSkuName "B1" -eventHubSkuName "Standard" -eventHubSkuTier "Standard" -enableStatisticsFunction "true"'
- stage: deploy_prd
displayName: 'Deploy to Production'
dependsOn: deploy_acc
variables:
- group: infra.prd
- group: invictus.prd
jobs:
- deployment: deploy_prd
displayName: 'Deploy to Production'
environment: Production
strategy:
runOnce:
deploy:
steps:
- download: '_build'
displayName: Download Artifact
- template: ./Templates/dashboard-release-steps.yaml
parameters:
azureSubscription: $(Infra.Environment.ServiceConnection)
scriptPath: '$(Pipeline.Workspace)/_build/dashboard/Deploy.ps1'
deployScriptParameters: '-resourcePrefix $(Infra.Environment.ResourcePrefix) -ArtifactsPath $(Pipeline.Workspace)/_build/dashboard -ResourceGroupName $(Infra.Environment.CustomerPrefix)-$(Infra.Environment.ShortName)-invictus -VariableGroupName invictus.$(Infra.Environment.ShortName) -devOpsObjectId "$(Infra.DevOps.Object.Id)" -servicePlanSkuName "P1V2" -eventHubSkuName "Standard" -eventHubSkuTier "Standard" -enableStatisticsFunction "true"'
20 changes: 16 additions & 4 deletions framework/installation/framework-buildpipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ The pipeline will use variables stored in a variable group, so before creating t

Create a variable group named {prefix}.Invictus.Installation and add these variables:

- **Invictus.Installation.StorageAccount&#46;Name**: invictusreleases
- **Invictus.Installation.StorageAccount.Name**: invictusreleases
- **Invictus.Installation.StorageAccount.Dashboard.SasToken**: value provided by Codit Software
- **Invictus.Installation.StorageAccount.Framework.SasToken**: value provided by Codit Software

Once you have the variable group, we can now proceed to creating the build pipeline.

## Create the build pipeline
## YAML Pipeline
Add the files and folders from [this](./pipelines) location to your DevOps repo.
This contains an example YAML pipelines to build the Invictus for Azure Framework, change the [framework.build.yaml](./pipelines/framework.build.yaml) file according to your needs, for example change the trigger path:
``` yaml
paths:
include:
- /src/customer.azure.invictus
```

Afterwards add the [framework.build.yaml](./pipelines/framework.build.yaml) in your DevOps environment as a pipeline, once you've saved the build pipeline you can create the [release pipeline](framework-releasepipeline.md).

## Classic Pipeline
### Create the build pipeline

Create a new build pipeline, starting with an empty template with this naming: {prefix}.Invictus.Framework.

Expand All @@ -31,7 +43,7 @@ The build will have only 2 tasks:
- A powershell task to pull the resources from blob
- A publish artifacts task

### Powershell task
#### Powershell task

Add a PowerShell task to the pipeline and name it **Pull Framework**, then point the script path to the powershell you downloaded at the beginning of this guide.

Expand All @@ -50,7 +62,7 @@ or configure it with these:
- **SaveLocation** (mandatory): `$(build.artifactstagingdirectory)`
- **UseBeta** (optional): by default this is false and will look for the resources in the prod folder, when set to true it will use the resources from the staging folder.

### Publish Artifacts task
#### Publish Artifacts task

Add a Publish build artifacts task to the pipeline and name it **Publish Framework**, use `$(Build.ArtifactStagingDirectory)` as the path to publish (or the SaveLocation argument you specified in the previous task).

Expand Down
Loading

0 comments on commit b864d64

Please sign in to comment.