diff --git a/Jenkinsfile b/Jenkinsfile index 8597db5..329ee92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ pipeline{ } } } - stage('MetricCheck'){ + stage('MetricCheck or code coverage'){ steps{ sh 'mvn cobertura:cobertura -Dcobertura.report.format=xml' diff --git a/JenkinsfileforMasterSalvesetup b/JenkinsfileforMasterSalvesetup new file mode 100644 index 0000000..13d3d33 --- /dev/null +++ b/JenkinsfileforMasterSalvesetup @@ -0,0 +1,97 @@ +pipeline{ + + tools{ + jdk 'myjava' + maven 'mymaven' +} +agent none + + + +stages{ + + stage('Clone repo') + { + agent {label 'Jenkinsslave'} + steps{ + + git 'https://github.com/ephrash/DevOpsCodeDemo.git' + + } + + } + stage('Compile the code') + { + agent any + steps{ + git 'https://github.com/ephrash/DevOpsCodeDemo.git' + + sh 'mvn compile' + + } + + } + + stage('Code Review') + { + agent any + steps{ + + sh 'mvn pmd:pmd' + + } + + } + + + stage('test the code') + { + agent {label 'Jenkinsslave'} + steps{ + echo 'Testing' + sh 'mvn test' + + + } + + post{ + + success{ + junit 'target/surefire-reports/*.xml' + } + } + } + + stage('Coverage of the code') + { + agent {label 'Jenkinsslave'} + steps{ + + sh 'mvn cobertura:cobertura -Dcobertura.report.format=xml' + + + } + + post{ + + success{ + cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'target/site/cobertura/coverage.xml', conditionalCoverageTargets: '70, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false + } + } + } + + + stage('Package the code') + { + agent {label 'Jenkinsslave'} + steps{ + + sh 'mvn package' + + } + + } + +} + +}