-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MMC-12] Update application properties
- Loading branch information
1 parent
7fd8424
commit 4066562
Showing
5 changed files
with
335 additions
and
87 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Build your Java project and run tests with Apache Maven. | ||
# Add steps that analyze code, save build artifacts, deploy, and more: | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/java | ||
|
||
trigger: | ||
- main | ||
|
||
pool: | ||
#vmImage: 'ubuntu-latest' | ||
vmImage: ubuntu-22.04 | ||
|
||
#variables: | ||
# MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository | ||
# MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' | ||
|
||
steps: | ||
# - task: Cache@2 | ||
# inputs: | ||
# key: 'maven | "$(Agent.OS)" | pom.xml' | ||
# restoreKeys: | | ||
# maven | "$(Agent.OS)" | ||
# maven | ||
# path: $(MAVEN_CACHE_FOLDER) | ||
# displayName: Cache Maven local repo | ||
|
||
- task: SonarCloudPrepare@1 | ||
displayName: 'Prepare SonarCloud analysis configuration' | ||
inputs: | ||
SonarCloud: '$(SONARCLOUD_SERVICE_CONN)' | ||
organization: '$(SONARCLOUD_ORG)' | ||
scannerMode: Other | ||
extraProperties: | | ||
sonar.projectKey=$(SONARCLOUD_PROJECT_KEY) | ||
sonar.projectName=$(SONARCLOUD_PROJECT_NAME) | ||
sonar.exclusions='**/enums/**, **/model/**, **/dto/**, **/*Constant*, **/*Config.java, **/*Scheduler.java, **/*Application.java, **/src/test/**, **/Dummy*.java' | ||
# - task: DownloadSecureFile@1 | ||
# displayName: 'download settings.xml for Maven' | ||
# name: settingsxml | ||
# inputs: | ||
# secureFile: '$(SETTINGS_XML_RO_SECURE_FILE_NAME)' | ||
# retryCount: '2' | ||
|
||
# options: '-B -s $(settingsxml.secureFilePath)' | ||
- task: Maven@3 | ||
inputs: | ||
mavenPomFile: 'pom.xml' | ||
goals: 'clean org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent verify org.jacoco:jacoco-maven-plugin:0.8.8:report org.jacoco:jacoco-maven-plugin:0.8.8:report-aggregate ' | ||
options: '-B' | ||
publishJUnitResults: true | ||
testResultsFiles: '**/surefire-reports/TEST-*.xml' | ||
javaHomeOption: 'JDKVersion' | ||
jdkVersionOption: '1.17' | ||
mavenVersionOption: 'Default' | ||
mavenAuthenticateFeed: false | ||
effectivePomSkip: false | ||
sonarQubeRunAnalysis: false | ||
- bash: xmlReportPaths=$(find "$(pwd)" -path '*jacoco.xml' | sed 's/.*/&/' | tr '\n' ','); echo "##vso[task.setvariable variable=xmlReportPaths]$xmlReportPaths" | ||
displayName: finding jacoco.xml | ||
|
||
# options: '-B -s $(settingsxml.secureFilePath) -Dsonar.coverage.jacoco.xmlReportPaths=$(xmlReportPaths)' | ||
|
||
- task: Maven@3 | ||
inputs: | ||
mavenPomFile: 'pom.xml' | ||
goals: 'sonar:sonar' | ||
options: '-B -Dsonar.coverage.jacoco.xmlReportPaths=$(xmlReportPaths)' | ||
publishJUnitResults: false | ||
javaHomeOption: 'JDKVersion' | ||
jdkVersionOption: '1.17' | ||
mavenVersionOption: 'Default' | ||
mavenAuthenticateFeed: false | ||
effectivePomSkip: false | ||
sonarQubeRunAnalysis: true | ||
isJacocoCoverageReportXML: false | ||
sqMavenPluginVersionChoice: 'latest' | ||
- task: SonarCloudPublish@1 | ||
inputs: | ||
pollingTimeoutSec: '300' |
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 |
---|---|---|
@@ -0,0 +1,192 @@ | ||
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker | ||
|
||
parameters: | ||
- name: 'executeBuild' | ||
displayName: 'Launch maven and docker build' | ||
type: boolean | ||
default: true | ||
|
||
trigger: | ||
branches: | ||
include: | ||
- release-* | ||
- main | ||
paths: | ||
include: | ||
- src/* | ||
- helm/* | ||
- pom.xml | ||
- Dockerfile | ||
|
||
pr: none | ||
|
||
resources: | ||
- repo: self | ||
|
||
variables: | ||
|
||
# vmImageNameDefault: 'ubuntu-latest' | ||
vmImageNameDefault: ubuntu-22.04 | ||
|
||
imageRepository: '$(K8S_IMAGE_REPOSITORY_NAME)' | ||
deployNamespace: '$(DEPLOY_NAMESPACE)' | ||
helmReleaseName : '$(HELM_RELEASE_NAME)' | ||
settingsXmlROsecureFileName: '$(SETTINGS_XML_RO_SECURE_FILE_NAME)' | ||
settingsXmlSecureFileName: '$(SETTINGS_XML_RO_SECURE_FILE_NAME)' | ||
canDeploy: true | ||
|
||
# If the branch is develop or a feature branch starting with CEN, deploy in DEV environment | ||
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/release-dev') }}: | ||
environment: 'DEV' | ||
dockerRegistryServiceConnection: '$(DEV_CONTAINER_REGISTRY_SERVICE_CONN)' | ||
kubernetesServiceConnection: '$(DEV_KUBERNETES_SERVICE_CONN)' | ||
containerRegistry: '$(DEV_CONTAINER_REGISTRY_NAME)' | ||
selfHostedAgentPool: $(DEV_AGENT_POOL) | ||
|
||
${{ elseif startsWith(variables['Build.SourceBranch'], 'refs/heads/release-uat') }}: | ||
environment: 'UAT' | ||
dockerRegistryServiceConnection: '$(UAT_CONTAINER_REGISTRY_SERVICE_CONN)' | ||
kubernetesServiceConnection: '$(UAT_KUBERNETES_SERVICE_CONN)' | ||
containerRegistry: '$(UAT_CONTAINER_REGISTRY_NAME)' | ||
selfHostedAgentPool: $(UAT_AGENT_POOL) | ||
|
||
${{ elseif or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),eq(variables['Build.SourceBranch'], 'refs/heads/release-prod')) }}: | ||
environment: 'PROD' | ||
dockerRegistryServiceConnection: '$(PROD_CONTAINER_REGISTRY_SERVICE_CONN)' | ||
kubernetesServiceConnection: '$(PROD_KUBERNETES_SERVICE_CONN)' | ||
containerRegistry: '$(PROD_CONTAINER_REGISTRY_NAME)' | ||
selfHostedAgentPool: $(PROD_AGENT_POOL) | ||
|
||
${{ else }}: | ||
environment: 'DEV' | ||
dockerRegistryServiceConnection: '$(DEV_CONTAINER_REGISTRY_SERVICE_CONN)' | ||
kubernetesServiceConnection: '$(DEV_KUBERNETES_SERVICE_CONN)' | ||
containerRegistry: '$(DEV_CONTAINER_REGISTRY_NAME)' | ||
selfHostedAgentPool: $(DEV_AGENT_POOL) | ||
|
||
stages: | ||
- stage: 'pom_version' | ||
displayName: Release | ||
condition: eq(variables.canDeploy, true) | ||
jobs: | ||
- job: POM | ||
displayName: POM | ||
pool: | ||
vmImage: $(vmImageNameDefault) | ||
steps: | ||
- task: Bash@3 | ||
displayName: Get POM version | ||
name: getpomversion | ||
condition: and(succeeded(), eq(variables.canDeploy, true)) | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
echo "##vso[task.setvariable variable=outputpomversion;isOutput=true]$version" | ||
failOnStderr: true | ||
|
||
- stage: 'build' | ||
displayName: 'Build_and_Publish_to_${{ variables.environment }}' | ||
dependsOn: 'pom_version' | ||
variables: | ||
pomversion: $[ stageDependencies.Release.POM.outputs['getpomversion.outputpomversion'] ] | ||
jobs: | ||
- job: Build | ||
displayName: Build | ||
pool: | ||
vmImage: $(vmImageNameDefault) | ||
steps: | ||
- task: Docker@2 | ||
condition: and(succeeded(), ${{ parameters.executeBuild }}) | ||
displayName: 'Publish_image_to_${{ variables.environment }}' | ||
inputs: | ||
containerRegistry: '$(dockerRegistryServiceConnection)' | ||
repository: '$(imageRepository)' | ||
command: 'buildAndPush' | ||
tags: | | ||
$(Build.BuildId) | ||
latest | ||
$(pomversion) | ||
# - task: PublishPipelineArtifact@1 | ||
# displayName: 'Publish Artifact manifests' | ||
# condition: and(succeeded(), eq(variables.canDeploy, true)) | ||
# inputs: | ||
# targetPath: '$(Build.Repository.LocalPath)/manifests' | ||
# artifact: 'manifests' | ||
# publishLocation: 'pipeline' | ||
|
||
- stage: 'publish_artifact_helm' | ||
displayName: 'Publish_artifact_Helm' | ||
dependsOn: ['build'] | ||
jobs: | ||
- job: Publish_artifact_helm | ||
displayName: Publish_artifact_helm | ||
pool: | ||
vmImage: $(vmImageNameDefault) | ||
steps: | ||
- task: PublishPipelineArtifact@1 | ||
displayName: 'Publish Artifact manifests' | ||
condition: succeeded() | ||
inputs: | ||
targetPath: '$(Build.Repository.LocalPath)/helm' | ||
artifact: 'helm' | ||
publishLocation: 'pipeline' | ||
|
||
- stage: 'deploy' | ||
displayName: 'Deploy to ${{ variables.environment }} K8S' | ||
dependsOn: ['publish_artifact_helm'] | ||
condition: and(succeeded(), eq(variables.canDeploy, true)) | ||
variables: | ||
pomversion: $[ stageDependencies.Release.POM.outputs['getpomversion.outputpomversion'] ] | ||
jobs: | ||
- deployment: 'Deploy_to_${{ variables.environment }}' | ||
displayName: 'Deploy to ${{ variables.environment }} K8S' | ||
pool: | ||
name: $(selfHostedAgentPool) | ||
environment: '$(environment)' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- download: none | ||
- task: DownloadPipelineArtifact@2 | ||
inputs: | ||
buildType: 'current' | ||
artifactName: 'helm' | ||
targetPath: '$(Pipeline.Workspace)/helm' | ||
- task: KubectlInstaller@0 | ||
- task: Bash@3 | ||
name: helm_dependency_build | ||
displayName: Helm dependency build | ||
inputs: | ||
workingDirectory: '$(Pipeline.Workspace)/helm' | ||
targetType: 'inline' | ||
script: | | ||
helm repo add pagopa-microservice https://pagopa.github.io/aks-microservice-chart-blueprint | ||
helm dep build | ||
failOnStderr: true | ||
- task: HelmDeploy@0 | ||
displayName: Helm upgrade | ||
inputs: | ||
kubernetesServiceEndpoint: ${{ variables.kubernetesServiceConnection }} | ||
namespace: '$(deployNamespace)' | ||
command: upgrade | ||
chartType: filepath | ||
chartPath: $(Pipeline.Workspace)/helm | ||
chartName: ${{ variables.helmReleaseName }} | ||
releaseName: ${{ variables.helmReleaseName }} | ||
valueFile: "$(Pipeline.Workspace)/helm/values-${{ lower(variables.environment) }}.yaml" | ||
install: true | ||
waitForExecution: true | ||
arguments: "--timeout 5m0s --debug" | ||
- task: KubernetesManifest@0 | ||
displayName: Patch | ||
inputs: | ||
kubernetesServiceConnection: ${{ variables.kubernetesServiceConnection }} | ||
namespace: '$(deployNamespace)' | ||
action: patch | ||
kind: deployment | ||
name: '$(helmReleaseName)-microservice-chart' | ||
mergeStrategy: strategic | ||
patch: '{"spec":{"template":{"metadata":{"annotations":{"buildNumber":"$(Build.BuildNumber)"}}}}}' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.