97 lines
2.3 KiB
YAML
97 lines
2.3 KiB
YAML
default:
|
|
image: maven:3-amazoncorretto-17-alpine
|
|
|
|
stages:
|
|
- build
|
|
- on_commit
|
|
- sonarcloud_scan
|
|
- deploy_pages
|
|
|
|
variables:
|
|
GITLAB_CLONE_DIR: "/builds/th-schwarz/CloudflareDNS-java"
|
|
GITLAB_USERNAME: $GITLAB_USERNAME
|
|
GITLAB_USEREMAIL: GITLAB_USEREMAIL
|
|
SONAR_HOST_URL: $SONAR_HOST_URL
|
|
SONAR_PROJECT_KEY: "thischwa_CloudflareDNS-java"
|
|
SONAR_ORGANIZATION: "thischwa"
|
|
SONAR_TOKEN: $SONAR_TOKEN
|
|
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
|
|
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
|
API_EMAIL: $API_EMAIL
|
|
API_KEY: $API_KEY
|
|
API_TOKEN: $API_TOKEN
|
|
|
|
build:
|
|
stage: build
|
|
script:
|
|
- echo "Running package..."
|
|
- cd ${GITLAB_CLONE_DIR}
|
|
- mvn clean package
|
|
artifacts:
|
|
paths:
|
|
- target/
|
|
except:
|
|
- tags
|
|
|
|
on_commits:
|
|
stage: on_commit
|
|
dependencies:
|
|
- build
|
|
script:
|
|
- echo "on_commit DONE"
|
|
only:
|
|
- /^feature.*$/
|
|
- merge_request
|
|
- develop
|
|
|
|
sonarcloud_scan:
|
|
stage: sonarcloud_scan
|
|
dependencies:
|
|
- build
|
|
script:
|
|
- mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
|
|
only:
|
|
- merge_requests
|
|
- develop
|
|
|
|
pages:
|
|
stage: on_commit
|
|
script:
|
|
- echo "Deploying GitLab Pages from docs/"
|
|
- mkdir public
|
|
- cp -r docs/* public/
|
|
artifacts:
|
|
paths:
|
|
- public
|
|
only:
|
|
- develop
|
|
|
|
javadoc:
|
|
stage: deploy_pages
|
|
before_script:
|
|
- apk update && apk add git
|
|
- git config --global user.name "${GITLAB_USERNAME}"
|
|
- git config --global user.email "${GITLAB_USEREMAIL}"
|
|
- git fetch origin ${CI_COMMIT_REF_NAME}
|
|
- git checkout ${CI_COMMIT_REF_NAME}
|
|
script:
|
|
- rm -rf docs/apidocs
|
|
- mvn javadoc:javadoc -DskipTests -Pjavadoc
|
|
- |
|
|
if ! git diff --quiet -- docs/apidocs; then
|
|
git add docs/apidocs
|
|
git commit -m "Update Javadocs [skip ci]"
|
|
git push https://${GITLAB_USERNAME}:${CI_PUSH_TOKEN}@gitlab.com/th-schwarz/CloudflareDNS-java.git ${CI_COMMIT_REF_NAME}
|
|
echo "Commits found and pushed"
|
|
[ ! -d public ] && mkdir public || echo "Directory 'public' already exists"
|
|
cp -r docs/* public/
|
|
echo "Copied javadoc files to public folder"
|
|
else
|
|
echo "No changes to commit"
|
|
fi
|
|
when: manual
|
|
artifacts:
|
|
paths:
|
|
- public
|
|
rules:
|
|
- if: '$CI_COMMIT_REF_NAME == "develop"' |