Java (With Maven)

Example Java (With Maven) Pipeline

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:

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:

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