Skip to content

Commit

Permalink
Merge pull request #447 from isogeo/3.4.1
Browse files Browse the repository at this point in the history
[3.4.1] Add on-premises deployement to Azure Pipeline
  • Loading branch information
SimonSAMPERE authored Sep 27, 2022
2 parents 6722093 + e69231e commit 8dd7433
Showing 1 changed file with 72 additions and 60 deletions.
132 changes: 72 additions & 60 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trigger:
batch: true
branches:
include:
- master
- master
tags:
include:
- "*"
Expand All @@ -17,12 +17,14 @@ pr:
# -- GLOBAL VARIABLES ------------------------------------------------------------------
variables:
PLUGIN_NAME: Isogeo
QGIS_VERSION_TAG: release-3_10
QGIS_VERSION_TAG: release-3_16
QGIS_IMAGE: qgis/qgis
pythonVersion: "3.7"
vmImageName: "windows-2019"
VERSION_NAME: $[replace(variables['Build.SourceBranch'], 'refs/tags/', '')]
VERSION_SUFIX: $[replace(variables['VERSION_NAME'], '.', '_')]
TAG_NAME: $[replace(variables['Build.SourceBranch'], 'refs/tags/', '')]
ZIP_NAME: $(SERVICE_NAME)-$(TAG_NAME).zip
azureSubscription : $(AZURE_SUBSCRIPTION)
date: $[format('{0:dd}.{0:MM}.{0:yyyy}', pipeline.startTime)]

# -- STAGES ----------------------------------------------------------------------------
stages:
Expand Down Expand Up @@ -76,11 +78,7 @@ stages:
# -- BUILD --------------------------------------------------------------------------
displayName: "Build and package"
dependsOn: Lint
condition: |
and(
succeeded(),
ne(variables['System.PullRequest.SourceBranch'], 'docs')
)
condition: succeeded()

jobs:
# UI COMPILATION
Expand All @@ -94,7 +92,7 @@ stages:
- checkout: none

- task: DownloadPipelineArtifact@2
displayName: "Download artifact previously saved"
displayName: "Download formatted source code previously saved"
inputs:
buildType: "current"
artifact: "FORMATTED_$(pyPiPackageName)_$(Build.SourceBranchName)_$(Build.BuildId)"
Expand Down Expand Up @@ -150,7 +148,7 @@ stages:
- checkout: none

- task: DownloadPipelineArtifact@2
displayName: "Download artifact previously saved"
displayName: "Download compiled source code previously saved"
inputs:
buildType: "current"
artifactName: "COMPILED_$(Build.SourceBranchName)_$(Build.BuildId)"
Expand All @@ -172,9 +170,8 @@ stages:
path: $(System.DefaultWorkingDirectory)/build/latest/isogeo_search_engine.zip
artifact: "PACKAGED_$(Build.SourceBranchName)_$(Build.BuildId)"

- stage: DeployPackage
# -- DEPLOY --------------------------------------------------------------------------
displayName: "Deploy package"
- stage: PublishtoGitHub
displayName: "Publish to GitHub"
dependsOn:
- Build
condition: |
Expand All @@ -194,7 +191,7 @@ stages:
- checkout: none

- task: DownloadPipelineArtifact@2
displayName: "Download artifact previously saved"
displayName: "Download packaged source code previously saved"
inputs:
buildType: "current"
artifactName: "PACKAGED_$(Build.SourceBranchName)_$(Build.BuildId)"
Expand All @@ -214,60 +211,75 @@ stages:
changeLogType: 'commitBased'


#####Upload pluginqgis to blobstorage######
- stage: PublishToAzure
displayName: "Publish to Azure"
dependsOn:
- Build
condition: |
and(
succeeded(),
contains(variables['Build.SourceBranch'], 'tags')
)
jobs:

- job: 'UploadToBlobStorage'
displayName: "Upload to Blob Storage (on premises)"
displayName : Building archive for Blob storage
pool:
vmImage: $(vmImageName)
steps:
- download: current
artifact: plugin
patterns: 'PACKAGED*'
vmImage: $(vmImageName)

steps:
- checkout: none

- task: DownloadPipelineArtifact@2
displayName: "Download packaged source code previously saved"
inputs:
buildType: "current"
artifactName: "PACKAGED_$(Build.SourceBranchName)_$(Build.BuildId)"
targetPath: "$(System.DefaultWorkingDirectory)"

- script: dir
displayName: Rename
- script: mv $(System.DefaultWorkingDirectory)\isogeo_search_engine.zip $(System.DefaultWorkingDirectory)\$(ZIP_NAME)
displayName: Rename image file name with correct version

- task: AzureCLI@1
displayName: Upload image to images blob tag version
inputs:
azureSubscription: 'Isogeo - MPN(82885610-5841-4749-8d71-46f56b643ad2)'
scriptLocation: 'inlineScript'
inlineScript: |
az storage blob upload-batch -d isogeoonpremises -s $(build.sourcesDirectory) --pattern *.zip --blob-endpoint https://isogeoonpremises.blob.core.windows.net --sas-token '"$(AZURE_STORAGE_SAS_TOKEN)"' --account-key '"$(AZURE_STORAGE_KEY)"' --destination-path /plugin-qgis

azureSubscription: $(azureSubscription)
scriptLocation: inlineScript
inlineScript: |
az storage blob upload-batch -d $(SERVICE_NAME) -s ./ --pattern $(ZIP_NAME) --blob-endpoint $(BLOB_STORAGE_URL) --sas-token '"$(AZURE_STORAGE_SAS_TOKEN)"' --account-key '"$(AZURE_STORAGE_KEY)"'
## Update and overwrite to azure container versions.json file ##
- stage: Update_versions
displayName: Update versions.json
jobs:
- job: Updatejson
displayName: Update_version_json
- job: 'UpdateVersionJSON'
displayName: Update versions.json
dependsOn: "UploadToBlobStorage"
pool:
vmImage: $(vmImageName)
vmImage: 'ubuntu-latest'

steps:
- script: sudo apt-get install jq
displayName: Install jq tools

- script: sudo apt-get install jq
displayName: Install jq tools

- task: AzureCLI@1
inputs:
azureSubscription: 'Isogeo - MPN(82885610-5841-4749-8d71-46f56b643ad2)'
scriptLocation: inlineScript
inlineScript: |
az storage blob download --account-name isogeoonpremises --container-name images --file versions.json --blob-url https://isogeoonpremises.blob.core.windows.net/images/isogeoonpremises/versions.json
- script: jq --argjson version "$(<version.json)" '.plugin-qgis |= . + $version' versions.json > last.json
displayName: first stage

- script: cat last.json
displayName: read versions.json

- script: rm -rf versions.json && mv last.json versions.json
displayName: read versions.json

- task: AzureCLI@1
inputs:
azureSubscription: 'Isogeo - MPN(82885610-5841-4749-8d71-46f56b643ad2)'
- task: AzureCLI@1
displayName : Download versions.json
inputs:
azureSubscription: $(azureSubscription)
scriptLocation: inlineScript
inlineScript: |
az storage blob upload-batch -d isogeoonpremises -s ./ --pattern versions.json --blob-endpoint https://isogeoonpremises.blob.core.windows.net/images --sas-token '"$(AZURE_STORAGE_SAS_TOKEN)"' --account-key '"$(AZURE_STORAGE_KEY)"' --overwrite --destination-path /
az storage blob download --account-name isogeoonpremises --container-name versions --file versions.json --blob-url $(BLOB_STORAGE_URL)/versions/versions.json --account-key '"$(AZURE_STORAGE_KEY)"' --connection-string $(BLOB_CONNEXION_STRING)
- script : cat version.json | jq --arg date "$(date)" '."release-date" += $date' > version_date.json
displayName : Add date to version.json

- script: cat versions.json | jq --argjson version "$(<version_date.json)" '."$(SERVICE_NAME)"."$(TAG_NAME)" += $version' > new_versions.json
displayName: Add version to versions.json

- script : rm -rf versions.json && mv new_versions.json versions.json
displayName: Rename file

- task: AzureCLI@1
displayName: Write versions.json to the blob storage
inputs:
azureSubscription: $(azureSubscription)
scriptLocation: inlineScript
inlineScript: |
az storage blob upload-batch -d versions -s ./ --pattern versions.json --blob-endpoint $(BLOB_STORAGE_URL) --sas-token '"$(AZURE_STORAGE_SAS_TOKEN)"' --account-key '"$(AZURE_STORAGE_KEY)"' --overwrite

0 comments on commit 8dd7433

Please sign in to comment.