9e8cd3b6c3
Added support for caching SonarCloud analysis tasks and updated the Git depth setting to ensure proper branch
54 lines
1.3 KiB
YAML
54 lines
1.3 KiB
YAML
default:
|
|
image: maven:3-amazoncorretto-17-alpine
|
|
|
|
stages:
|
|
- pull
|
|
- on_commit
|
|
- sonarcloud_scan
|
|
|
|
variables:
|
|
GITLAB_CLONE_DIR: "/builds/thischwa/CloudflareDNS-java"
|
|
# GITLAB_CLONE_DIR: "cloudflaredns-java"
|
|
SONAR_HOST_URL: "https://sonarcloud.io"
|
|
SONAR_PROJECT_KEY: "th-schwarz_DynDRest"
|
|
SONAR_ORGANIZATION: "th-schwarz"
|
|
SONAR_TOKEN: "${SONAR_TOKEN_ENV_VAR}"
|
|
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
|
|
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
|
|
|
|
|
pull_source:
|
|
stage: pull
|
|
script:
|
|
- echo "Cloning GitHub repository..."
|
|
- git clone --depth 1 https://oauth2:${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/th-schwarz/CloudflareDNS-java.git ${GITLAB_CLONE_DIR}
|
|
- echo "Repository cloned successfully."
|
|
only:
|
|
- schedules
|
|
|
|
on_commits:
|
|
stage: on_commit
|
|
script:
|
|
- echo "Running tests..."
|
|
- cd ${GITLAB_CLONE_DIR}
|
|
- mvn clean test
|
|
only:
|
|
- /^feature.*$/
|
|
- merge_request
|
|
- develop
|
|
|
|
sonarcloud_scan:
|
|
stage: sonarcloud_scan
|
|
image:
|
|
name: sonarsource/sonar-scanner-cli:latest
|
|
entrypoint: [""]
|
|
cache:
|
|
key: "${CI_JOB_NAME}"
|
|
paths:
|
|
- .sonar/cache
|
|
script:
|
|
- sonar-scanner
|
|
only:
|
|
- merge_requests
|
|
- develop
|