From ef3e3defd47691a9d582235236fbc55d203bdefe Mon Sep 17 00:00:00 2001 From: Johannes Schnatterer Date: Tue, 10 Oct 2017 16:46:19 +0200 Subject: [PATCH] Jenkins: Archive JUnit results also on failing tests --- Jenkinsfile | 120 ++++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1e4acfee8..8ad049d76 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,75 +1,75 @@ #!groovy node { - cesFqdn = "ecosystem.cloudogu.net"; - cesUrl = "https://${cesFqdn}"; - credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME'); + cesFqdn = "ecosystem.cloudogu.net" + cesUrl = "https://${cesFqdn}" + credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME') - stage('Checkout') { - checkout scm - } + catchError { - stage('Build') { - mvn "-DskipTests clean package" - - // archive artifact - archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true - } - - parallel( - test: { - stage('Test') { - String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606"; - mvn "${jacoco}:prepare-agent test ${jacoco}:report" - - // Archive JUnit results, if any - junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml' - } - }, - integrationTest: { - stage('Integration Test') { - String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606"; - mvn "${jacoco}:prepare-agent-integration failsafe:integration-test ${jacoco}:report-integration" - - // Archive JUnit results, if any - junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/TEST-*.xml' - } - } - ) - - stage('SonarQube Analysis') { - withCredentials([credentials]) { - //noinspection GroovyAssignabilityCheck - mvn "org.codehaus.mojo:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=${cesUrl}/sonar " + - "-Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD} -Dsonar.exclusions=target/**" + stage('Checkout') { + checkout scm } + + stage('Build') { + mvn "-DskipTests clean package" + + // archive artifact + archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true + } + + parallel( + test: { + stage('Test') { + String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606"; + mvn "${jacoco}:prepare-agent test ${jacoco}:report" + } + }, + integrationTest: { + stage('Integration Test') { + String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606"; + mvn "${jacoco}:prepare-agent-integration failsafe:integration-test ${jacoco}:report-integration" + } + } + ) + + stage('SonarQube Analysis') { + withCredentials([credentials]) { + //noinspection GroovyAssignabilityCheck + mvn "org.codehaus.mojo:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=${cesUrl}/sonar " + + "-Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD} -Dsonar.exclusions=target/**" + } + } + + parallel( + deployArtifacts: { + stage('Deploy Artifacts') { + String releaseProp = "-DaltReleaseDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/releases/"; + String snapshotProp = "-DaltSnapshotDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/snapshots/"; + mvn "-DskipTests deploy ${releaseProp} ${snapshotProp}" + } + }, + deployApplication: { + + stage('Deploy Application') { + sh "ansible-playbook playbook.yaml" + } + } + ) } - parallel( - deployArtifacts: { - stage('Deploy Artifacts') { - String releaseProp = "-DaltReleaseDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/releases/"; - String snapshotProp = "-DaltSnapshotDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/snapshots/"; - mvn "-DskipTests deploy ${releaseProp} ${snapshotProp}" - } - }, - deployApplication: { - - stage('Deploy Application') { - sh "ansible-playbook playbook.yaml" - } - } - ) + // Archive Unit and integration test results, if any + junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/TEST-*.xml,**/target/surefire-reports/TEST-*.xml' } -String cesFqdn; -String cesUrl; -def credentials; +String cesFqdn +String cesUrl +def credentials void mvn(String args) { - writeSettingsXml() - sh "./mvnw -s settings.xml --batch-mode -V -U -e -Dsurefire.useFile=false ${args}" - sh 'rm -f settings.xml' + writeSettingsXml() + sh "./mvnw -s settings.xml --batch-mode -V -U -e -Dsurefire.useFile=false ${args}" + sh 'rm -f settings.xml' } void writeSettingsXml() {