Using the official maven docker image The image allows executing arbitrary maven goals: it's possible to pass freely all the supported options to the command

Run simple maven goal (defined in the POM)

pipeline:
  build:
    image: maven:3.5-jdk-8
    commands:
      - mvn clean

Run maven goal with environment:

pipeline:
  build:
    image: maven:3.5-jdk-8
    environment:
      - FOO=BAR
    commands:
      - mvn clean build

Run maven goal from a custom POM file (in the specified folder)

pipeline:
  build:
    image: maven:3.5-jdk-8
    commands:
      - mvn -f /path/to/pom/dir clean

Execute a more complex goal sequence from a custom POM file (in the specified folder)

pipeline:
  build:
    image: maven:3.5-jdk-8
    environment:
      - ENV_VAR_1=VALUE1
      - ENV_VAR_2=VALUE2
    commands:
      - mvn -f /path/to/pom/dir -PmyProfile -DskipTests clean package

Read more how to use this image on docker docs

Find more information about the maven project on the project's page here