Skip to main content

Java (With Maven)

Example YAML configuration for a project building a Java application with Maven.

Scenario

User is looking to create a pipeline that builds an artifact on any event or branch pushed to source control.

Steps

The following pipeline concepts are being used in the pipeline below:

tip

Pipeline must be stored in base of repository as .vela.yml or .vela.yaml

It is recommended to pin image: versions for production pipelines

version: "1"

steps:
- name: install
image: maven:latest
pull: always
commands:
- mvn install

- name: test
image: maven:latest
pull: always
commands:
- mvn test

- name: build
image: maven:latest
pull: always
commands:
- mvn package

Stages

The following pipeline concepts are being used in the pipeline below:

tip

Pipeline must be stored in base of repository as .vela.yml or .vela.yaml

It is recommended to pin image: versions for production pipelines

version: "1"
stages:
install:
steps:
- name: install
image: maven:latest
pull: always
commands:
- mvn install
test:
needs: [ install ]
steps:
- name: test
image: maven:latest
pull: always
environment:
GRADLE_USER_HOME: .gradle
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=1 -Dorg.gradle.parallel=false
commands:
- mvn test

build:
needs: [ install ]
steps:
- name: build
image: maven:latest
pull: always
environment:
GRADLE_USER_HOME: .gradle
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=1 -Dorg.gradle.parallel=false
commands:
- mvn package