From 5fca52ec34b02a2705bdece336eea780eebb2b08 Mon Sep 17 00:00:00 2001 From: Sohail Date: Wed, 8 Mar 2023 16:15:53 +0530 Subject: [PATCH] Added jenkins1 file --- Jenkinsfile | 10 ++++++++- Jenkinsfile1 | 31 ++++++++++++++++++++++++++ gradle-decl-jenkins | 54 ++++++++++++++++++++++++++++----------------- 3 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 Jenkinsfile1 diff --git a/Jenkinsfile b/Jenkinsfile index 98becc228..d3166b0f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,12 +11,20 @@ pipeline{ sh 'mvn package' } } + stage('copy artifact to s3') { + steps{ + sh "sudo mkdir -p /tmp/artifactory/${JOB_NAME}/${BUILD_ID} && sudo cp ./target/spring-petclinic-*.jar /tmp/artifactory/${JOB_NAME}/${BUILD_ID}" + sh "aws s3 sync /tmp/artifactory/${JOB_NAME}/${BUILD_ID}/ s3://spc.war" + } + + } } post{ success{ archiveArtifacts artifacts: '**/target/spring-petclinic-*.jar' - junit testResults: '**/surefire-reports/TEST-*.xml' + junit '**/surefire-reports/TEST-*.xml' + } diff --git a/Jenkinsfile1 b/Jenkinsfile1 new file mode 100644 index 000000000..b2f3308f1 --- /dev/null +++ b/Jenkinsfile1 @@ -0,0 +1,31 @@ +pipeline { + agent{ label 'node1'} + triggers{ + pollSCM('* * * * *') + } + + stages { + stage('vcs') { + steps { + git url: 'https://github.com/shaiksohail11/spring-petclinic.git', + branch: 'main' + + } + } + } + + stage('build') { + steps { + sh 'mvn package' + } + } + + stage('sonar analysis') { + steps { + withSonarQubeEnv('SONAR_CLOUD') { + sh 'mvn clean package sonar:sonar -Dsonar.organization=jenkins12' + } + } + } + +} \ No newline at end of file diff --git a/gradle-decl-jenkins b/gradle-decl-jenkins index 6204f30f9..2931e7a75 100644 --- a/gradle-decl-jenkins +++ b/gradle-decl-jenkins @@ -1,20 +1,34 @@ -pipeline{ - agent any - - stages{ - stage ('build') { - steps { - git branch: 'main', - url: 'https://github.com/shaiksohail11/spring-petclinic.git' - sh './gradlew build' - } - post { - - success { - junit '**/test-results/test/TEST-*.xml' - archiveArtifacts '**/libs/spring-petclinic-3.0.0.jar' -} -} -} -} -} +pipeline{ + agent { label 's3'} + triggers { + pollSCM('* * * * *') + } + stages { + stage ('vcs') { + steps { + git url: 'https://github.com/shaiksohail11/spring-petclinic.git', + branch: 'main' + sh 'mvn package' + } + stage('copy artifact to s3') { + + sh "sudo mkdir -p /artifactory/${JOB_NAME}/${BUILD_ID}" + sh "aws s3 cp ./target/spring-petclinic-3.0.0-SNAPSHOT.jar s3://spc.war" + + } + } + + + } + post{ + success{ + + archiveArtifacts artifacts: '**/target/spring-petclinic-*.jar' + junit '**/surefire-reports/TEST-*.xml' + + + + + } + } +} \ No newline at end of file