Skip to content

Commit

Permalink
fix wrong copy command for copying xunit-reports in gradle build
Browse files Browse the repository at this point in the history
  • Loading branch information
oalyman committed Jan 20, 2022
1 parent 198261b commit 729986c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ listed in the changelog.
### Fixed
- Cannot enable debug mode in some tasks ([#377](https://github.com/opendevstack/ods-pipeline/issues/377))
- Gradle task does not expose Nexus env variables ([#373](https://github.com/opendevstack/ods-pipeline/issues/373))
- Gradle build fails when it contains more than one test class ([#414](https://github.com/opendevstack/ods-pipeline/issues/414))

## [0.2.0] - 2021-12-22
### Added
Expand Down
2 changes: 1 addition & 1 deletion build/package/scripts/build-gradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ UNIT_TEST_RESULT_DIR="${BUILD_DIR}/test-results/test"
if [ -d "${UNIT_TEST_RESULT_DIR}" ]; then
UNIT_TEST_ARTIFACTS_DIR="${ARTIFACTS_DIR}/xunit-reports"
mkdir -p "${UNIT_TEST_ARTIFACTS_DIR}"
cp "${UNIT_TEST_RESULT_DIR}/"*.xml "${UNIT_TEST_ARTIFACTS_DIR}/${ARTIFACT_PREFIX}report.xml"
cp "${UNIT_TEST_RESULT_DIR}/"*.xml "${UNIT_TEST_ARTIFACTS_DIR}/${ARTIFACT_PREFIX}"

This comment has been minimized.

Copy link
@renedupont

renedupont Feb 24, 2022

Member

Shouldn't it rather be just
cp "${UNIT_TEST_RESULT_DIR}/"*.xml "${UNIT_TEST_ARTIFACTS_DIR}
considering that further above in the script $ARTIFACT_PREFIX is set like this:

if [ "${WORKING_DIR}" != "." ]; then
  WORKING_DIR="${ROOT_DIR}"
  ARTIFACT_PREFIX="${WORKING_DIR/\//-}-"
fi

?

This comment has been minimized.

Copy link
@oalyman

oalyman Feb 24, 2022

Author Contributor

yes, I think you are right the $ARTIFACT_PREFIX is not needed.

This comment has been minimized.

Copy link
@renedupont

renedupont Feb 24, 2022

Member

will fix it in #495

else
echo "Build failed: no unit test results found in ${UNIT_TEST_RESULT_DIR}"
exit 1
Expand Down
3 changes: 2 additions & 1 deletion test/tasks/ods-build-gradle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func TestTaskODSBuildGradle(t *testing.T) {
checkFilesExist(t, wsDir,
"docker/Dockerfile",
"docker/app.jar",
filepath.Join(pipelinectxt.XUnitReportsPath, "report.xml"),
filepath.Join(pipelinectxt.XUnitReportsPath, "TEST-ods.java.gradle.sample.app.AppTest.xml"),
filepath.Join(pipelinectxt.XUnitReportsPath, "TEST-ods.java.gradle.sample.app.AppTest2.xml"),
filepath.Join(pipelinectxt.CodeCoveragesPath, "coverage.xml"),
filepath.Join(pipelinectxt.SonarAnalysisPath, "analysis-report.md"),
filepath.Join(pipelinectxt.SonarAnalysisPath, "issues-report.csv"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package ods.java.gradle.sample.app;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

// this class exists to have more than one test xml in the end
class AppTest2 {
@Test void appHasAGreetingTwo() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}

0 comments on commit 729986c

Please sign in to comment.