Set up CI with Azure Pipelines

[skip ci]
This commit is contained in:
chandu 2024-12-11 14:38:00 +05:30
parent 2d01f6cbb2
commit 32acc380ea

52
azure-pipelines.yml Normal file
View file

@ -0,0 +1,52 @@
trigger:
- main # Adjust to your branch name
pool:
vmImage: 'ubuntu-latest'
variables:
- group: springpetclinic
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '17' # Specify the desired JDK version
jdkArchitectureOption: 'x64' # Choose architecture (x64 or x86)
jdkSourceOption: 'PreInstalled' # Use PreInstalled if available
displayName: 'Install Java 17'
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
options: '-B'
goals: 'clean package'
displayName: 'Maven Compile'
- task: SonarCloudPrepare@3
inputs:
SonarCloud: 'SONAR_CLOUD_1' # Replace with your SonarCloud service connection name
organization: '$(SONAR_ORGANIZATION)' # Replace with your SonarCloud organization name
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: '$(SONAR_PROJECT_KEY)' # Replace with your SonarCloud project key
cliProjectName: '$(SONAR_PROJECT)' # Replace with your SonarCloud project name
cliProjectVersion: '1.0'
extraProperties: |
sonar.java.binaries=target/classes
sonar.sources=src/main/java
sonar.tests=src/test/java
sonar.junit.reportPaths=target/surefire-reports
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
displayName: 'Prepare analysis on SonarCloud'
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
goals: 'verify sonar:sonar'
options: '-Dsonar.login=$(SONAR_TOKEN)'
displayName: 'Run SonarCloud Analysis'
- task: SonarCloudPublish@3
inputs:
pollingTimeoutSec: '300'
displayName: 'Publish Quality Gate Result'