-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
85 lines (76 loc) · 3.31 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Default image for linux builds
image: objectboxio/buildenv-android:2023-07-28
variables:
# Disable the Gradle daemon. Gradle may run in a Docker container with a shared
# Docker volume containing GRADLE_USER_HOME. If the container is stopped after a job
# Gradle daemons may get killed, preventing proper clean-up of lock files in GRADLE_USER_HOME.
# Use low priority processes to avoid Gradle builds consuming all build machine resources.
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.priority=low"
GITLAB_REPO_ARGS: "-PgitlabUrl=$CI_SERVER_URL -PgitlabTokenName=Job-Token -PgitlabToken=$CI_JOB_TOKEN"
CENTRAL_REPO_ARGS: "-PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PWD"
# CI_COMMIT_REF_SLUG is the branch or tag name, but web-safe (only 0-9, a-z)
VERSION_ARGS: "-PversionPostFix=$CI_COMMIT_REF_SLUG"
stages:
- test
- upload-to-internal
- upload-to-central
- triggers
# Common template to calculate version postfix
.common:
except: # Version postfix is derived from branch name
- tags
before_script:
# Print Gradle and JVM version info
- ./gradlew -version
# Add token for build tracker
- ./scripts/set-analysis-token.sh $JAVA_ANALYSIS_TOKENFILE
# Template for tests
.tests:
extends: .common
stage: test
script:
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean check
artifacts:
when: always
reports:
junit: "**/build/test-results/**/TEST-*.xml"
test:linux:
extends: .tests
tags: [ docker, x64 ]
test:windows:
extends: .tests
tags: [ windows ]
upload-to-internal:linux:
extends: .common
stage: upload-to-internal
tags: [ docker, x64 ]
except:
- main # Do not upload duplicate release artifacts
- pipelines # Do not upload artifacts if triggered by upstream project to save on disk space
- tags # Only upload artifacts from branches
script:
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
upload-to-central:linux:
extends: .common
stage: upload-to-central
tags: [ docker, x64 ]
only:
- publish
script:
# Note: can not use before_script for Chat notification as it would overwrite the one from .common (feel free to improve)
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java Gradle plugin:* $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..."
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS $CENTRAL_REPO_ARGS publishMavenJavaPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
- echo "Published successfully to Central - check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes."
after_script: # also runs on failure, so show CI_JOB_STATUS
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java Gradle plugin:* *$CI_JOB_STATUS* for $CI_JOB_NAME"
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "Check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes."
trigger-integ-tests:
stage: triggers
except:
- schedules # Do not trigger when run on schedule, integ tests have own schedule.
inherit:
variables: false
allow_failure: true # Branch might not exist, yet, in integ test project.
trigger:
project: objectbox/objectbox-integration-test
branch: $CI_COMMIT_BRANCH