Added jenkins1 file

This commit is contained in:
Sohail 2023-03-08 16:15:53 +05:30
parent c98dd02c5a
commit 5fca52ec34
3 changed files with 74 additions and 21 deletions

10
Jenkinsfile vendored
View file

@ -11,12 +11,20 @@ pipeline{
sh 'mvn package' 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{ post{
success{ success{
archiveArtifacts artifacts: '**/target/spring-petclinic-*.jar' archiveArtifacts artifacts: '**/target/spring-petclinic-*.jar'
junit testResults: '**/surefire-reports/TEST-*.xml' junit '**/surefire-reports/TEST-*.xml'
} }

31
Jenkinsfile1 Normal file
View file

@ -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'
}
}
}
}

View file

@ -1,20 +1,34 @@
pipeline{ pipeline{
agent any agent { label 's3'}
triggers {
stages{ pollSCM('* * * * *')
stage ('build') { }
steps { stages {
git branch: 'main', stage ('vcs') {
url: 'https://github.com/shaiksohail11/spring-petclinic.git' steps {
sh './gradlew build' git url: 'https://github.com/shaiksohail11/spring-petclinic.git',
} branch: 'main'
post { sh 'mvn package'
}
success { stage('copy artifact to s3') {
junit '**/test-results/test/TEST-*.xml'
archiveArtifacts '**/libs/spring-petclinic-3.0.0.jar' 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'
}
}
}