mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
added jenkins file and modified pom
This commit is contained in:
parent
d8fcd11e67
commit
751ce8e646
2 changed files with 88 additions and 2 deletions
63
Jenkinsfile
vendored
Normal file
63
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
tools {
|
||||||
|
jdk 'jdk17'
|
||||||
|
maven 'maven3'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
SONAR_AUTH_TOKEN = credentials('sonarfile') // Assumes you have stored your token in Jenkins Credentials
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('compile ') {
|
||||||
|
steps {
|
||||||
|
sh 'mvn compile'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('SonarQube Analysis') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Run Maven with SonarQube plugin for analysis
|
||||||
|
withSonarQubeEnv('SonarQubeScanner') { // 'SonarQubeScanner' is the name of the SonarQube server configured in Jenkins
|
||||||
|
sh """
|
||||||
|
mvn sonar:sonar -Dsonar.login=${SONAR_AUTH_TOKEN} \
|
||||||
|
-Dsonar.projectName=spring-petclinic \
|
||||||
|
-Dsonar.java.binaries=. \
|
||||||
|
-Dsonar.projectKey=spring-petclinic
|
||||||
|
"""
|
||||||
|
//mvn sonar:sonar sonar maven plugin command
|
||||||
|
//Command: $SCANNER_HOME/bin/sonar-scanner standalone sonarqub scanner command
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Maven Package') {
|
||||||
|
steps {
|
||||||
|
sh 'mvn clean package -DskipTests'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('OWASP Dependency-Check') {
|
||||||
|
steps {
|
||||||
|
dependencyCheck additionalArguments: '--scan target/', odcInstallation: 'OWASP Check'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build & push Docker Image') {
|
||||||
|
when {
|
||||||
|
branch 'Release'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
withDockerRegistry(credentialsId: 'c9b058e5-bfe6-41f8-9b5d-dc0b0d2955ac', toolName: 'docker') {
|
||||||
|
sh "docker build -t prasannakumarsinganamalla431/petclinic:${BUILD_NUMBER} -f .devcontainer/Dockerfile ."
|
||||||
|
sh "docker push prasannakumarsinganamalla431/petclinic:${BUILD_NUMBER}"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
23
pom.xml
23
pom.xml
|
@ -39,6 +39,11 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spring and Spring Boot dependencies -->
|
<!-- Spring and Spring Boot dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.8.6</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
@ -143,6 +148,12 @@
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||||
|
<artifactId>sonar-maven-plugin</artifactId>
|
||||||
|
<version>3.9.0.2155</version>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
@ -436,6 +447,18 @@
|
||||||
</pluginExecutions>
|
</pluginExecutions>
|
||||||
</lifecycleMappingMetadata>
|
</lifecycleMappingMetadata>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.owasp</groupId>
|
||||||
|
<artifactId>dependency-check-maven</artifactId>
|
||||||
|
<version>INSERT_VERSION_HERE</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|
Loading…
Reference in a new issue