Create pipeline job templates covering the maven lifecycle

Maven uses a build lifecycle to handle everything from compiling code to deploying an application.

For a CI pipeline, we should focus on creating atomic jobs covering the test, package, verify, and deploy phases in the lifecycle. All previous phases in the lifecycle are automatically executed by default, so an option to skip some phases should also be taken into account.

Tasks:

  • Create mvn test job
  • Create mvn package job
  • Create mvn verify job
  • Create mvn deploy job
  • Add ARGS variable in a base maven job to allow users to specify any command line arguments to any job

Example pseudo code:

.base-maven:
 variables:
  ARGS: ""

.maven-test:
 stage: test
 extends: .base-maven
 script:
  - mvn test $ARGS
Edited by Xinyuan Peric