-
Notifications
You must be signed in to change notification settings - Fork 69
/
Jenkinsfile
42 lines (38 loc) · 1.48 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pipeline {
agent any
tools {
maven 'maven3'
}
stages{
stage('checkout'){
steps{
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vcjain/jenkins-sonar-demo.git']])
}
}
stage('Build'){
steps{
echo 'Building Maven project'
sh 'mvn clean compile'
}
}
stage('Test'){
steps{
echo 'Building Maven project'
sh 'mvn test'
junit '**/target/surefire-reports/*.xml'
jacoco classPattern: '**/target/classes', exclusionPattern: '**/*Test*.class', execPattern: '**/target/jacoco.exec', inclusionPattern: '**/*.class', sourceExclusionPattern: 'generated/**/*.java', sourceInclusionPattern: '**/*.java'
}
}
stage('SonarQube Analysis'){
steps{
echo 'Scanning Maven project'
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
withSonarQubeEnv(installationName: 'sonarcloud', credentialsId: 'sonar-token') {
sh 'mvn sonar:sonar -Dsonar.projectKey=sonardemo -Dsonar.organization=vcjain -Dsonar.host.url=https://sonarcloud.io'
sh 'sleep 50'
}
}
}
}
}
}