Example Pipeline for Unit Test Results

JFrog Pipelines Documentation

ft:sourceType
Paligo

The following example pipeline demonstrates the process of generating unit test results in a Maven build and recording the results to the run log for later viewing in Pipelines.

The pipeline defines a GitRepo resource that contains the Java application, and a BuildInfo resource for the resulting build.

pipelines.resources.yml

resources:
  - name: java_app
    type: GitRepo
    configuration:
      gitProvider: MyGithub
      path: myproject/simple-maven-sample
      branches:
        include: master

  - name: my_build_info
    type: BuildInfo
    configuration:
      sourceArtifactory: myArtifactory
      buildName: simple-maven-sample
      buildNumber: 1

The pipeline executes a Maven build using the MvnBuild native step. It requires that the Maven project being built has been configured to use the Maven Surefire Plugin to perform unit tests and produce a junit-compatible test result file.

In the onComplete action of the execution block, the step will save the test result file to the run log by calling the save_tests utility function.

pipelines.steps.yml

pipelines:
  - name: java_pipeline
    steps:
      - name: build_app
        type: MvnBuild
        configuration:
          sourceLocation: .
          mvnCommand: clean install -ntp
          configFileLocation: .
          configFileName: mvn-art-config
          autoPublishBuildInfo: true
          integrations:
            - name: myArtifactory
          inputResources:
            - name: java_app
          outputResources:
            - name: my_build_info
          runtime:
            type: image
            image:
              auto:
                language: java
                versions:
                  - "11"
        execution:
          onComplete:
            - save_tests $res_java_app_resourcePath/target/surefire-reports/

After the pipeline has finished running, the test results for the build_app step can be viewed in the run log.

test_07Apr23.png