diff --git a/Jenkinsfile b/Jenkinsfile index a59602b..3d9c0e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,20 +1,59 @@ -node { - def mvnHome - stage('Build') { // for display purposes - // Get some code from a GitHub repository - git 'https://github.com/jglick/simple-maven-project-with-tests.git' - // Get the Maven tool. - // ** NOTE: This 'M3' Maven tool must be configured - // ** in the global configuration. - mvnHome = tool 'M3' - sh "'${mvnHome}/bin/mvn' clean compile" - } - stage('Unit Test') { - sh "'${mvnHome}/bin/mvn' test" - junit '**/target/surefire-reports/TEST-*.xml' - } - stage('Publish') { - sh "'${mvnHome}/bin/mvn' package" - archive 'target/*.jar' - } -} +pipeline { + agent none + stages { + stage('Build & Test') { + agent { + node { + label 'docker' + } + + } + steps { + sh 'mvn -Dmaven.test.failure.ignore clean package' + stash(name: 'build-test-artifacts', includes: '**/target/surefire-reports/TEST-*.xml,target/*.jar') + } + } + stage('Report & Publish') { + parallel { + stage('Report & Publish') { + agent { + node { + label 'docker' + } + + } + steps { + unstash 'build-test-artifacts' + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts(artifacts: 'target/*.jar', onlyIfSuccessful: true) + } + } + stage('Publish to Artifactory') { + agent { + node { + label 'docker' + } + + } + steps { + script { + unstash 'build-test-artifacts' + + def server = Artifactory.server 'MyArtifactory1' + def uploadSpec = """{ + "files": [ + { + "pattern": "target/*.jar", + "target": "example-repo-local/${BRANCH_NAME}/${BUILD_NUMBER}/" + } + ] + }""" + server.upload(uploadSpec) + } + + } + } + } + } + } +} \ No newline at end of file