Skip to content

Commit 423c98e

Browse files
committed
add step for sonarqube
1 parent 1aefa29 commit 423c98e

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

jenkins/Jenkinsfile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pipeline {
2+
23
agent {
34
label 'docker' // <--- Aquí especificas el nodo por su etiqueta
45
}
@@ -9,12 +10,34 @@ pipeline {
910
args '-v /root/.m2:/root/.m2'
1011
}
1112
}*/
13+
14+
environment {
15+
SONAR_HOST_URL = 'http://sonarqube:9000' // URL de tu SonarQube
16+
SONAR_TOKEN = credentials('sonar-token-id') // Usar "Secret Text" en Jenkins
17+
}
18+
1219
stages {
20+
21+
stage('Checkout') {
22+
steps {
23+
checkout scm
24+
}
25+
}
26+
27+
stage('SonarQube Analysis') {
28+
steps {
29+
withSonarQubeEnv('SonarQube Server') { // Nombre del server configurado en Jenkins
30+
sh 'mvn clean verify sonar:sonar -Dsonar.projectKey=my-app -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN'
31+
}
32+
}
33+
}
34+
1335
stage('Build') {
1436
steps {
1537
sh 'mvn -B -DskipTests clean package'
1638
}
1739
}
40+
1841
stage('Test') {
1942
steps {
2043
sh 'mvn test'
@@ -25,11 +48,13 @@ pipeline {
2548
}
2649
}
2750
}
51+
2852
stage('Vulnerability Analysis') {
2953
steps {
3054
sh 'mvn org.owasp:dependency-check-maven:check'
3155
}
3256
}
57+
3358
stage('Build Docker Image') {
3459
steps {
3560
script {
@@ -49,11 +74,13 @@ pipeline {
4974
//sh 'docker push $DOCKER_USERNAME/my-app-image:latest'
5075
}
5176
}
52-
}
77+
}
78+
5379
stage('Deliver') {
5480
steps {
5581
sh './jenkins/scripts/deliver.sh'
5682
}
5783
}
84+
5885
}
5986
}

0 commit comments

Comments
 (0)