From 1ba785013dcd74ba3e3b9dbdb1cde7cff844f4e4 Mon Sep 17 00:00:00 2001 From: sridhar Date: Wed, 13 Sep 2023 16:10:22 +0530 Subject: [PATCH] added cnew repo --- Jenkinsfile | 138 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 38 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 44e05483d..16f1975da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,51 +1,113 @@ pipeline{ - agent{label 'java-17'} + agent{label 'java'} + tools { + maven 'maven 3.9.4' + } stages{ stage('VCS'){ steps{ git credentialsId: 'GIT_HUB_CREDENTIALS', url: 'https://github.com/Cloud-and-devops-notes/spring-petclinic-jenkins.git', - branch: 'main' + branch: 'spcbranch' } } - stage('artifact build'){ - steps{ - sh 'docker image build -t spc-mvn .' - sh 'docker image list' - - } - } - stage('artifact') { - steps { - archiveArtifacts artifacts: '**/target/spring-petclinic-3.1.0-SNAPSHOT.jar', - onlyIfSuccessful: true - junit testResults: '**/surefire-reports/TEST-*.xml' - } + // stage('nexus'){ + // steps{ + // nexusArtifactUploader artifacts: [[artifactId: 'spring-petclinic', classifier: '', file: '/home/ubuntu/spring-petclinic/target/spring-petclinic-3.1.0-SNAPSHOT.jar', type: 'jar']], credentialsId: 'nexus', groupId: 'org.springframework.samples', nexusUrl: '54.237.114.152:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: '3.1.0-SNAPSHOT' + // } + // } + stage('Build & SonarQube Scan') { + steps { + sh 'mvn --version' + // withSonarQubeEnv('SONAR_CLOUD') { + // sh 'mvn clean install sonar:sonar -Dsonar.organization=qtdevopssohail123 -Dsonar.token=8c15adacf466a5ccd721f4f7cdb2c4bf17df84ab -Dsonar.projectKey=qtdevopssohail123' + } + } } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// pipeline{ +// agent{label 'java-17'} +// stages{ +// stage('VCS'){ +// steps{ +// git credentialsId: 'GIT_HUB_CREDENTIALS', +// url: 'https://github.com/Cloud-and-devops-notes/spring-petclinic-jenkins.git', +// branch: 'main' +// } +// } +// stage('artifact build'){ +// steps{ +// sh 'docker image build -t spc-mvn .' +// sh 'docker image list' + +// } +// } +// stage('artifact') { +// steps { +// archiveArtifacts artifacts: '**/target/spring-petclinic-3.1.0-SNAPSHOT.jar', +// onlyIfSuccessful: true +// junit testResults: '**/surefire-reports/TEST-*.xml' +// } +// } - stage('docker login'){ - steps{ - withCredentials([string(credentialsId: 'DOCKER_HUB_PASSWORD',variable: 'PASSWORD')]) { - sh 'docker login -u sridhar006 -p $PASSWORD' - } - } - } - stage('docker push image '){ - steps{ - sh 'docker image tag spc-mvn sridhar006/spc-mvn:${BUILD_ID}' - sh 'docker push sridhar006/spc-mvn:${BUILD_ID}' +// stage('docker login'){ +// steps{ +// withCredentials([string(credentialsId: 'DOCKER_HUB_PASSWORD',variable: 'PASSWORD')]) { +// sh 'docker login -u sridhar006 -p $PASSWORD' +// } +// } +// } +// stage('docker push image '){ +// steps{ +// sh 'docker image tag spc-mvn sridhar006/spc-mvn:${BUILD_ID}' +// sh 'docker push sridhar006/spc-mvn:${BUILD_ID}' - } - } - stage("kubernetes deployment"){ - steps{ - sh """ - - """ - sh 'kubectl apply -f deployement.yaml' - } +// } +// } +// stage("kubernetes deployment"){ +// steps{ +// sh 'kubectl apply -f deployement.yaml' +// } - } +// } - } - } +// } +// }