Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM adoptopenjdk/openjdk11:alpine-jre

ARG artifact=target/spring-boot-multi.jar

WORKDIR /app

COPY ${artifact} app.jar

ENTRYPOINT ["java","-jar","app.jar"]
47 changes: 47 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pipeline {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root -v /var/run/docker.sock:/var/run/docker.sock'
}
}
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/prashanths-07/spring-boot-multibranch.git'
}
}
stage('Build and Test') {
steps {
sh 'ls -ltr'
sh 'cd spring-boot-multibranch && mvn clean package'
}
}
stage('Static Code Analysis') {
environment {
SONAR_URL = "http://<server_url>:9000"
}
steps {
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_AUTH_TOKEN')]) {
sh 'cd spring-boot-multibranch && mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'
}
}
}
stage('Build and Push Docker Image') {
environment {
DOCKER_IMAGE = "sprs16/multibranch-ci:${BUILD_NUMBER}"
DOCKERFILE_LOCATION = "spring-boot-multibranch/Dockerfile"
REGISTRY_CREDENTIALS = credentials('docker-cred')
}
steps {
script {
sh 'cd spring-boot-multibranch && docker build -t ${DOCKER_IMAGE} .'
def dockerImage = docker.image("${DOCKER_IMAGE}")
docker.withRegistry('https://index.docker.io/v1/', "docker-cred") {
dockerImage.push()
}
}
}
}
}
}