From 41b4cd9d38cb00a7668c913a5784d8958fdfc814 Mon Sep 17 00:00:00 2001 From: Saulo Valenzuela Date: Thu, 9 Jan 2025 13:03:08 +0100 Subject: [PATCH] pipeline: migrate to stratus-templates --- .azure/azure-pipelines.pr.yml | 25 +++++++------- .azure/azure-pipelines.prod.yml | 28 ++++++++------- .azure/azure-pipelines.ref.yml | 60 +++++++++++++++++++++------------ .azure/deploy-infra.yml | 33 ------------------ .azure/prod.parameters.json | 5 ++- .azure/ref.parameters.json | 5 ++- 6 files changed, 75 insertions(+), 81 deletions(-) delete mode 100644 .azure/deploy-infra.yml diff --git a/.azure/azure-pipelines.pr.yml b/.azure/azure-pipelines.pr.yml index b8f87ee2..70599289 100644 --- a/.azure/azure-pipelines.pr.yml +++ b/.azure/azure-pipelines.pr.yml @@ -4,24 +4,25 @@ pr: variables: - group: studadm-general-params - - name: imageName - value: kursinfo-web - - name: dockerfilePath - value: '$(Pipeline.Workspace)/github/Dockerfile' - - name: tag - value: '$(Build.SourceVersion)' resources: repositories: - - repository: cet-iac + - repository: stratus-templates type: git - name: Cloud Excellence Team/cet-iac + name: Cloud Excellence Team/stratus-templates ref: main pool: vmImage: 'ubuntu-latest' -steps: - - template: templates/test/npm-test.yml@cet-iac - parameters: - nodeVersion: '18' +extends: + template: templates/security/security-scans.yml@stratus-templates + parameters: + break: false + jobs: + - job: test + displayName: 'Test' + steps: + - template: /templates/test/npm.yml@stratus-templates + parameters: + nodeVersion: 18.x diff --git a/.azure/azure-pipelines.prod.yml b/.azure/azure-pipelines.prod.yml index 475b39de..99f37406 100644 --- a/.azure/azure-pipelines.prod.yml +++ b/.azure/azure-pipelines.prod.yml @@ -8,9 +8,6 @@ parameters: variables: - group: studadm-general-params - - group: studadm-spoke1-prod - - name: appName - value: kursinfo-web-prod - name: imageName value: kursinfo-web - name: parametersFileName @@ -18,19 +15,24 @@ variables: resources: repositories: - - repository: cet-iac + - repository: stratus-templates type: git - name: Cloud Excellence Team/cet-iac + name: Cloud Excellence Team/stratus-templates ref: main pool: vmImage: 'ubuntu-latest' -steps: - - template: templates/app-service/update-image.yml@cet-iac - parameters: - parametersFileName: $(parametersFileName) - appName: $(appName) - imageName: $(imageName) - tag: ${{ parameters.imageTag }} - isApi: false +extends: + template: templates/security/security-scans.yml@stratus-templates + parameters: + break: false + jobs: + - job: update + displayName: 'Update App Service' + steps: + - template: /templates/app-service/update-image.yml@stratus-templates + parameters: + parametersFileName: $(parametersFileName) + imageName: $(imageName) + tag: ${{ parameters.imageTag }} diff --git a/.azure/azure-pipelines.ref.yml b/.azure/azure-pipelines.ref.yml index 2e0ee88f..78a4c4e7 100644 --- a/.azure/azure-pipelines.ref.yml +++ b/.azure/azure-pipelines.ref.yml @@ -6,11 +6,8 @@ trigger: variables: - group: studadm-general-params - - group: studadm-spoke1-ref - name: dockerfilePath value: '$(Pipeline.Workspace)/github/Dockerfile' - - name: appName - value: kursinfo-web-ref - name: imageName value: kursinfo-web - name: tag @@ -20,28 +17,49 @@ variables: resources: repositories: - - repository: cet-iac + - repository: stratus-templates type: git - name: Cloud Excellence Team/cet-iac + name: Cloud Excellence Team/stratus-templates ref: main pool: vmImage: 'ubuntu-latest' -steps: - - template: templates/test/npm-test.yml@cet-iac - parameters: - nodeVersion: '18' - - template: templates/docker/push.yml@cet-iac - parameters: - dockerFilePath: $(dockerfilePath) - imageName: $(imageName) - tag: $(tag) +extends: + template: templates/security/security-scans.yml@stratus-templates + parameters: + break: false + jobs: + - job: sonarqube + displayName: 'SonarQube and NPM Test' + steps: + - template: /templates/codescan/sonarqube.yml@stratus-templates + parameters: + projectName: $(imageName) + steps: + - template: /templates/test/npm.yml@stratus-templates + parameters: + nodeVersion: 18.x - - template: templates/app-service/update-image.yml@cet-iac - parameters: - parametersFileName: $(parametersFileName) - appName: $(appName) - imageName: $(imageName) - tag: $(tag) - isApi: false + - job: build_push + dependsOn: sonarqube + displayName: 'Build and Push image' + steps: + - template: /templates/docker/push.yml@stratus-templates + parameters: + build: true + break: false + dockerFilePath: $(dockerfilePath) + imageName: $(imageName) + tag: $(tag) + + - job: update + dependsOn: + - build_push + displayName: 'Update App Service' + steps: + - template: /templates/app-service/update-image.yml@stratus-templates + parameters: + parametersFileName: $(parametersFileName) + imageName: $(imageName) + tag: $(tag) \ No newline at end of file diff --git a/.azure/deploy-infra.yml b/.azure/deploy-infra.yml deleted file mode 100644 index d6f27dfb..00000000 --- a/.azure/deploy-infra.yml +++ /dev/null @@ -1,33 +0,0 @@ -trigger: none -pr: none - -parameters: - - name: generalParams - type: string - displayName: General params name (from library, -general-params) - - name: spokeParams - type: string - displayName: Spoke params name (from library, -) - - name: parametersFileName - type: string - displayName: Parameters filename (from .azure folder, .parameters.json) - -variables: - - group: ${{ parameters.generalParams }} - - group: ${{ parameters.spokeParams }} - -resources: - repositories: - - repository: cet-iac - type: git - name: Cloud Excellence Team/cet-iac - ref: main - -pool: - vmImage: 'ubuntu-latest' - -steps: - - template: templates/app-service/infra.yml@cet-iac - parameters: - location: $(location) - parametersFileName: ${{ parameters.parametersFileName }} diff --git a/.azure/prod.parameters.json b/.azure/prod.parameters.json index 8264d99b..ca85e9ee 100644 --- a/.azure/prod.parameters.json +++ b/.azure/prod.parameters.json @@ -3,7 +3,10 @@ "contentVersion": "1.0.0.0", "parameters": { "appName": { - "value": "kursinfo-web-prod" + "value": "kursinfo-web" + }, + "env": { + "value": "prod" }, "secretNames": { "value": [ diff --git a/.azure/ref.parameters.json b/.azure/ref.parameters.json index ee45fa11..b9c31734 100644 --- a/.azure/ref.parameters.json +++ b/.azure/ref.parameters.json @@ -3,7 +3,10 @@ "contentVersion": "1.0.0.0", "parameters": { "appName": { - "value": "kursinfo-web-ref" + "value": "kursinfo-web" + }, + "env": { + "value": "ref" }, "secretNames": { "value": [