Browse documentation

Build a Java project

This tutorial creates a pipeline for https://github.com/heitorfm/hello-spring with Git Clone, Maven Build, Test Report, and Docker Build actions.

Create the project and pipeline

  1. Open Projects and create a project named hello-spring.

  2. Open Pipelines and create a pipeline named java-build for that project.

  3. Open Edit Flow.

Add the actions

Add and configure these actions:

Reference name Action Configuration

clone

Git Clone

Repository: https://github.com/heitorfm/hello-spring; directory: source

build

Maven Build

Goals: clean, package; POM: source/pom.xml

tests

Test Report

Reports: source/*/surefire-reports/.xml; format: JUNIT

image

Docker Build

Image tag: hello-spring:latest; context: source

Connect the graph in this order:

clone -> build -> tests -> image

The Test Report action reads the JUnit XML generated by Maven and exposes test counts on the run page.

Equivalent ICE

ICE-1.0.0
codinamo >= 1.0.0

@pipeline {
    name: "java-build"
    description: "Build hello-spring"
    environment: "default"
    continueOnError: false

    @actions {
        clone: action.GIT_CLONE({
            params: {
                repositoryUrl: "https://github.com/heitorfm/hello-spring",
                targetDirectory: "source"
            }
        })
        build: action.MAVEN_BUILD({
            params: {
                goals: ["clean", "package"],
                pomPath: "source/pom.xml"
            }
        })
        tests: action.TEST_REPORT({
            params: {
                allowEmpty: false,
                failOnFailure: true,
                format: "JUNIT",
                reports: "source/**/surefire-reports/*.xml"
            }
        })
        image: action.DOCKER_BUILD({
            params: {
                contextPath: "source",
                imageTag: "hello-spring:latest"
            }
        })
    }

    @flow {
        clone -> build
        build -> tests
        tests -> image
    }
}

Run and inspect

  1. Save the pipeline.

  2. Return to the pipeline page and select Run.

  3. Open the execution.

  4. Confirm that all four steps succeeded.

  5. Inspect the test report and expand the logs for any failed action.

The clone.commit_sha, build.artifact_path, and image.image_name outputs are available to later actions. See Variables and action outputs.