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
-
Open Projects and create a project named
hello-spring. -
Open Pipelines and create a pipeline named
java-buildfor that project. -
Open Edit Flow.
Add the actions
Add and configure these actions:
| Reference name | Action | Configuration |
|---|---|---|
|
Git Clone |
Repository: |
|
Maven Build |
Goals: |
|
Test Report |
Reports: |
|
Docker Build |
Image tag: |
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
-
Save the pipeline.
-
Return to the pipeline page and select Run.
-
Open the execution.
-
Confirm that all four steps succeeded.
-
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.