Skip to content
Snippets Groups Projects
Commit 92d822d4 authored by Daniel Dehennin's avatar Daniel Dehennin
Browse files

feat(maven): validate the project with `.maven:validate`

.maven:validate
===============

Validate the project is correct and all necessary information is
available.

USAGE
=====

include:
  - project: EOLE/Infra/ci-tools
    ref: stable
    file: /templates/Maven.yaml

stages:
  - lint

maven validate: {extends: '.maven:validate'}
parent 68473fc3
No related branches found
No related tags found
3 merge requests!66Publish new release,!65Prepare new release,!63Resolve "Add CI templates for Java Maven projects"
# -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.maven:validate`: validate the project is correct and all
# necessary information is available
#
# - `.maven:base`: base template job used to factorize variables
# declaration
#
---
#
# .maven:validate
# ===============
#
# Validate the project is correct and all necessary information is
# available.
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Maven.yaml
#
# stages:
# - lint
#
# maven validate: {extends: '.maven:validate'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.on-branch` rules templates or it must be overriden by
# the extending job to feet your need
#
# OPTIONAL VARIABLES
# ==================
#
# - `SRC_DIR`: directory of the java sources containing the `pom.xml`,
# default to `.`
#
# - `MAVEN_IMAGE`: name of the `maven` docker image to use
#
# - `MAVEN_OPTS`: default to "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
#
# - `MAVEN_CLI_OPTS`: default to "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
#
# - `MAVEN_CLI_ARGS`: optional arguments to pass to `maven validate`
# command, empty by default
#
# USED CI VARIABLES
# =================
#
.maven:validate:
stage: lint
extends: .maven:base
cache:
# This job update dependencies
policy: pull-push
script:
- echo -e "\e[0Ksection_start:$(date +%s):maven-validate\r\e[0KExecute 'mvn validate -f ${SRC_DIR} ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}'"
- mvn validate -f "${SRC_DIR}" ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}
- echo -e "\e[0Ksection_end:$(date +%s):maven-validate\r\e[0K"
.maven:base:
image: ${MAVEN_IMAGE}
extends: .on-branch
variables:
MAVEN_IMAGE: hub.eole.education/proxyhub/library/maven:3.8.6-openjdk-8-slim
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
MAVEN_CLI_ARGS: ""
cache:
key:
files:
- pom.xml
paths:
- .m2/repository
# Validate will push the cache
policy: pull
...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment