Issue
Please refer the below Jenkins Pipeline
stages {
stage("Build Matrix Project") {
matrix {
axes {
axis {
name "CITY_NAME"
values "CITY_01", "CITY_02"
}
}
stages {
stage("Build and Run Tests") {
steps {
....
}
}
stage("Generate Reports") {
steps {
allure commandline: "Allure 2.18.1", includeProperties: false, jdk: "", results: [[path: "target/allure-results"]], reportBuildPolicy: "ALWAYS"
}
}
}
}
}
}
The allure report gets generated successfully for both CITY_01 and CITY_02. But the allure results of CITY_02 over-writes CITY_01.
Please let me know, how to fix this?
Solution
What you can do is run all the matrix builds in parallel as you do now, then instead of publishing the report stash it for later use and save its name in a global list.
After the parallel execution is over (or in the post section) unstash all the reports and publish them altogether as a single report (in a separate none matrix stage) that will contain all the tests from all matrix configurations.
Something like:
REPORTS =[]
stages {
stage("Build Matrix Project") {
matrix {
axes {
axis {
name "CITY_NAME"
values "CITY_01", "CITY_02"
}
}
stages {
stage("Build and Run Tests for ${CITY_NAME}") {
steps {
// build code & run tests
// stash the results
stash name: CITY_NAME, includes: "target/allure-results/*.*"
REPORTS.add("${CITY_NAME}")
}
}
}
}
}
stage("Generate Allure Report") {
steps {
REPORTS.each {
dir(it) {
unstash name: it
}
}
def resultList = REPORTS.collect { [path:"${it}/target/allure-results"] }
allure commandline: "Allure 2.18.1", includeProperties: false, results: resultList, reportBuildPolicy: "ALWAYS"
}
}
}
Answered By - Noam Helmer
Answer Checked By - Clifford M. (JavaFixing Volunteer)