From a2ac09daffc31fe983440e3380f4b8d6077dbe94 Mon Sep 17 00:00:00 2001 From: Yaswitha Date: Mon, 26 Sep 2022 09:10:12 +0530 Subject: [PATCH 1/2] commited some changes in jenkins file using scriptd pipeline --- Jenkinsfile | 83 +++++++---------------------------------------------- 1 file changed, 11 insertions(+), 72 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c456b75f757..5c3e411656e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,73 +1,12 @@ -pipeline { - agent { label 'JDK11' } - options { - timeout(time: 1, unit: 'HOURS') - } - triggers { - cron('0 * * * *') - } - stages { - stage('Source Code') { - steps { - git url: 'https://github.com/GitPracticeRepo/spring-petclinic.git', - branch: 'main' - } - - } - stage('Artifactory-Configuration') { - steps { - rtMavenDeployer ( - id: 'spc-deployer', - serverId: 'JFROG_INSTANCE', - releaseRepo: 'qtecomm-libs-release-local', - snapshotRepo: 'qtecomm-libs-snapshot-local', - - ) - } - } - stage('Build the Code and sonarqube-analysis') { - steps { - // withSonarQubeEnv('SONAR_LATEST') { - // sh script: "mvn ${params.GOAL} sonar:sonar" - // } - - rtMavenRun ( - // Tool name from Jenkins configuration. - tool: 'MVN_DEFAULT', - pom: 'pom.xml', - goals: 'clean install', - // Maven options. - deployerId: 'spc-deployer', - ) - - // stash name: 'spc-build-jar', includes: 'target/*.jar' - } - } - stage('reporting') { - steps { - junit testResults: 'target/surefire-reports/*.xml' - } - } - // stage("Quality Gate") { - // steps { - // timeout(time: 1, unit: 'HOURS') { - // waitForQualityGate abortPipeline: true - // } - // } - // } - - } - // post { - // success { - // // send the success email - // echo "Success" - // mail bcc: '', body: "BUILD URL: ${BUILD_URL} TEST RESULTS ${RUN_TESTS_DISPLAY_URL} ", cc: '', from: 'devops@qtdevops.com', replyTo: '', - // subject: "${JOB_BASE_NAME}: Build ${BUILD_ID} Succeded", to: 'qtdevops@gmail.com' - // } - // unsuccessful { - // //send the unsuccess email - // mail bcc: '', body: "BUILD URL: ${BUILD_URL} TEST RESULTS ${RUN_TESTS_DISPLAY_URL} ", cc: '', from: 'devops@qtdevops.com', replyTo: '', - // subject: "${JOB_BASE_NAME}: Build ${BUILD_ID} Failed", to: 'qtdevops@gmail.com' - // } - // } +node{ +stage('vcs') { + git branch: 'scripted_pipeline', url: 'https://github.com/yaswitha94/spring-petclinic.git' +} +stage('build') { + sh 'mvn package' +} +stage('archieve artifacts') { + junit '**/surefire-reports/*.xml' + junit '**/surefire-reports/*.xml' +} } \ No newline at end of file From b91b6e7f76637f2a7ef4b2efa163b34c8c37b5f7 Mon Sep 17 00:00:00 2001 From: Yaswitha Date: Mon, 26 Sep 2022 09:45:59 +0530 Subject: [PATCH 2/2] declarative pipeline --- Jenkinsfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5c3e411656e..463ec800551 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,14 @@ -node{ -stage('vcs') { - git branch: 'scripted_pipeline', url: 'https://github.com/yaswitha94/spring-petclinic.git' -} -stage('build') { - sh 'mvn package' -} -stage('archieve artifacts') { - junit '**/surefire-reports/*.xml' - junit '**/surefire-reports/*.xml' -} +pipeline { + agent any + stages { + stage('Getting code') { + steps { + git url: 'https://github.com/yaswitha94/spring-petclinic.git', + branch: 'declarative_pipeline' + sh 'mvn package' + } + + + } + } } \ No newline at end of file