1

I am trying to setup build scripts for Gitlab CI for a Java/ project with Gradle. The project has three different modules A, B and C, with modules B and C being dependent on the module A.

All three have a build.gradle file and unit tests inside them. There is also a build.gradle file in the root of the project. I am trying to have test reports available in GitLab CI when a new push is made. I managed to have the test executed with ease by executing the check gradle command with a script similar to this one:

test:
  stage: test
  script:
    - ./gradlew check

THis, however, does not provide any test reports. In the logs I only see something like this:

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :check UP-TO-DATE
> Task :A:compileJava
> Task :A:processResources NO-SOURCE
> Task :A:classes
> Task :A:jar
> Task :B:compileJava
> Task :B:processResources NO-SOURCE
> Task :B2:classes
> Task :B:compileTestJava
> Task :B:processTestResources
> Task :B:testClasses
> Task :B:test
> Task :B:check
> Task :A:compileTestJava
> Task :Ar:processTestResources NO-SOURCE
> Task :A:testClasses
> Task :A:test
> Task :A:check
BUILD SUCCESSFUL in 42s

It is good that the build fails if the test fails, but I don't have any indication to what tests were executed, what tests failed or any other information.

Can anyone help with some resources or hints on how to solve this.

1 Answer 1

1

The Ci.CD pipeline allows having a list of artifacts:

test:
  stage: test
  script:
    - ./gradlew test
  artifacts:
    when: always
    reports:
      junit: 
        - a/build/test-results/test/**/TEST-*.xml
        - b/build/test-results/test/**/TEST-*.xml
        - c/build/test-results/test/**/TEST-*.xml
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 7, 2022 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.