Disable pull stage and refactor build process in CI config.

The pull stage is commented out to streamline the CI pipeline. Refactored the build job to generate artifacts while ensuring test tasks depend on the output of the build job. Added dependencies to relevant stages for smoother execution flow.
This commit is contained in:
2025-04-06 19:02:28 +02:00
parent 7810cb7d8e
commit 131ee9970a
+22 -12
View File
@@ -2,13 +2,13 @@ default:
image: maven:3-amazoncorretto-17-alpine image: maven:3-amazoncorretto-17-alpine
stages: stages:
- pull #- pull
- on_commit - on_commit
- sonarcloud_scan - sonarcloud_scan
variables: variables:
GITLAB_CLONE_DIR: "/builds/thischwa/CloudflareDNS-java" GITLAB_CLONE_DIR: "/builds/thischwa/CloudflareDNS-java"
# GITLAB_CLONE_DIR: "cloudflaredns-java" # GITLAB_CLONE_DIR: "cloudflaredns-java"
SONAR_HOST_URL: "https://sonarcloud.io" SONAR_HOST_URL: "https://sonarcloud.io"
SONAR_PROJECT_KEY: "th-schwarz_DynDRest" SONAR_PROJECT_KEY: "th-schwarz_DynDRest"
SONAR_ORGANIZATION: "th-schwarz" SONAR_ORGANIZATION: "th-schwarz"
@@ -17,21 +17,30 @@ variables:
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
pull_source: #pull_source:
stage: pull # 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
build:
script: script:
- echo "Cloning GitHub repository..." - mvn clean package -DskipTests
- git clone --depth 1 https://oauth2:${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/th-schwarz/CloudflareDNS-java.git ${GITLAB_CLONE_DIR} artifacts:
- echo "Repository cloned successfully." paths:
only: - target/
- schedules
on_commits: on_commits:
stage: on_commit stage: on_commit
dependencies:
- build
script: script:
- echo "Running tests..." - echo "Running tests..."
- cd ${GITLAB_CLONE_DIR} - cd ${GITLAB_CLONE_DIR}
- mvn clean test - mvn test
cache: cache:
key: "${CI_JOB_NAME}" key: "${CI_JOB_NAME}"
paths: paths:
@@ -43,15 +52,16 @@ on_commits:
sonarcloud_scan: sonarcloud_scan:
stage: sonarcloud_scan stage: sonarcloud_scan
dependencies:
- build
image: image:
name: sonarsource/sonar-scanner-cli:latest name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""] entrypoint: [ "" ]
cache: cache:
key: "${CI_JOB_NAME}" key: "${CI_JOB_NAME}"
paths: paths:
- .maven-cache - .maven-cache
script: script:
- mvn clean package -DskipTests
- sonar-scanner -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.organization=${SONAR_ORGANIZATION} -Dsonar.token=${SONAR_TOKEN} -Dsonar.java.binaries=target/classes - sonar-scanner -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.organization=${SONAR_ORGANIZATION} -Dsonar.token=${SONAR_TOKEN} -Dsonar.java.binaries=target/classes
only: only:
- merge_requests - merge_requests