Jenkinsfile
Jenkinsfile
agent any
stages{
stage('Git Checkout'){
steps{
git branch: 'main', url: 'https://github.com/vikash-kumar01/demo-
counter-app.git'
}
}
stage('UNIT Testing'){
steps{
sh 'mvn test'
}
}
stage('Integration testing'){
steps{
sh 'mvn verify -DskipUnitTests'
}
}
stage('Maven Build'){
steps{
sh 'mvn clean install'
}
}
stage('SonarQube analysis'){
steps{
script{
withSonarQubeEnv(credentialsId: 'sonar-api') {
sh 'mvn clean package sonar:sonar'
}
}
}
}
stage('Quality Gate status'){
steps{
script{
steps{
script{
nexusArtifactUploader artifacts:
[
[
artifactId: 'springboot',
classifier: '', file: 'target/Uber.jar',
type: 'jar'
]
],
credentialsId: 'nexus-auth',
groupId: 'com.example',
nexusUrl: '3.234.253.249:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: nexusRepo,
version: "${readPomVersion.version}"
}
}
}
stage('Docker Image Build'){
steps{
script {
sh 'docker image build -t $JOB_NAME:v1.$BUILD_ID .'
sh 'docker image tag $JOB_NAME:v1.$BUILD_ID
vikashashoke/$JOB_NAME:v1.$BUILD_ID'
sh 'docker image tag $JOB_NAME:v1.$BUILD_ID
vikashashoke/$JOB_NAME:latest'
}
}
}
steps{
script{
withCredentials([string(credentialsId: 'dockerhub_creds',
variable: 'dockerhub_creds')]) {