image: maven:3.9.4-eclipse-temurin-17-focal

cache:
  #key: "${CI_JOB_NAME}"
  paths:
    - .m2/repository/

before_script:
- echo $CI_JOB_NAME
- echo $CI_PROJECT_DIR

stages:
- build
- review
    
variables:
  SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
  SONAR_TOKEN: "4d48d600a7f5a14f56560921009177fb9007f5f6" #admin
  SONAR_HOST_URL: "http://39.99.155.97:9000"
  GIT_DEPTH: 0
  MAVEN_CLI_OPTS: "-P prod-suite -s .m2/settings.xml --batch-mode -Dmaven.test.skip=true"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

compile:
  stage: build
  script:
    - echo "============================= 开始进行编译 ============================="
    - mvn $MAVEN_CLI_OPTS compile
  allow_failure: false
  only:
    - merge_requests
    - master
    - develop
  tags:
    - tip-root

sonarqube-check:
  stage: review
  script:
    - echo "============================= 开始进行Sonar代码审查 ============================="
    - mvn $MAVEN_CLI_OPTS verify sonar:sonar # -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=300
  allow_failure: true
  only:
    - merge_requests
    - master
    - develop
  tags:
    - tip-root
  when: manual