11# https://docs.gitlab.com/ci/yaml/
22
3- # Default Docker image (currently only supporting Docker Linux containers)
4- # This should match the image used to build the JVM database libraries (so Address Sanitizer library matches).
5- # When updating, check if the test-jdk jobs need changing.
6- image : objectboxio/buildenv-core:2025-07-03 # With JDK 21
7-
83# Assumes these environment variables are configured in GitLab CI/CD Settings:
94# - OBX_READ_PACKAGES_TOKEN
105# - SONATYPE_USER
@@ -36,7 +31,7 @@ variables:
3631 GITLAB_PUBLISH_ARGS : " -PgitlabPublishTokenName=Job-Token -PgitlabPublishToken=$CI_JOB_TOKEN"
3732 CENTRAL_PUBLISH_ARGS : " -PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PWD"
3833 # CI_COMMIT_REF_SLUG is the branch or tag name, but web-safe (only 0-9, a-z)
39- VERSION_ARGS : " -PversionPostFix =$CI_COMMIT_REF_SLUG"
34+ VERSION_ARGS : " -PversionSuffix =$CI_COMMIT_REF_SLUG"
4035
4136# Using multiple test stages to avoid running some things in parallel (see job notes).
4237stages :
@@ -65,28 +60,47 @@ workflow:
6560 # In all other cases, create a pipeline
6661 - when : always
6762
68- test :
69- stage : test
63+ .docker_linux_x64_android : &docker_linux_x64_android
7064 tags :
7165 - docker
7266 - linux
7367 - x64
68+ image : objectboxio/buildenv-android:2024-12-09 # With JDK 21, Android build-tools;35.0.0 and platforms;android-35 pre-installed
7469 variables :
7570 # Image defaults to POSIX (ASCII), set a compatible locale so UTF-8 tests that interact with the file system work.
7671 # Check with 'locale -a' for available locales.
7772 LC_ALL : " C.UTF-8"
73+
74+ .test_base :
7875 before_script :
7976 # Print Gradle and JVM version info
8077 - ./gradlew -version
8178 # Remove any previous JVM (Hotspot) crash log.
8279 # "|| true" for an OK exit code if no file is found
8380 - rm **/hs_err_pid*.log || true
81+ # By default, don't compile and test the Android APIs (only do in test job), there is currently no benefit to test
82+ # them using multiple platforms or JDKs.
83+ script : ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build -PexcludeAndroid=true
84+ artifacts :
85+ when : always
86+ paths :
87+ - " **/hs_err_pid*.log" # Only on JVM (Hotspot) crash
88+ reports :
89+ junit : " **/build/test-results/**/TEST-*.xml"
90+
91+ test :
92+ << : *docker_linux_x64_android
93+ extends : .test_base
94+ stage : test
95+ # Overwrite script key to run through ASAN script, compile and test Android APIs and test build of Web API docs.
96+ # Note: Address sanitizer is only available on Linux runners (see script).
8497 script :
8598 # build to assemble, run tests and spotbugs
8699 # javadocForWeb to catch API docs errors before releasing
87100 # Temporarily disable testing with Address Sanitizer until buildenv images are modernized, see #273
88101 # - ./scripts/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean build javadocForWeb
89102 - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build javadocForWeb
103+ # Overwrite artifacts key to archive spotbugs reports
90104 artifacts :
91105 when : always
92106 paths :
@@ -95,88 +109,59 @@ test:
95109 reports :
96110 junit : " **/build/test-results/**/TEST-*.xml"
97111
98- .test-template :
99- before_script :
100- # Print Gradle and JVM version info
101- - ./gradlew -version
102- # Remove any previous JVM (Hotspot) crash log.
103- # "|| true" for an OK exit code if no file is found
104- - rm **/hs_err_pid*.log || true
105- artifacts :
106- when : always
107- paths :
108- - " **/hs_err_pid*.log" # Only on JVM (Hotspot) crash.
109- reports :
110- junit : " **/build/test-results/**/TEST-*.xml"
111-
112- test-windows :
113- extends : .test-template
114- needs : ["test"]
115- tags :
116- - windows-jdk
117- - x64
118- script : ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
119-
120- test-macos :
121- extends : .test-template
122- needs : ["test"]
123- tags :
124- - jdk
125- - mac
126- script : ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
127-
128- # Address sanitizer is only available on Linux runners (see script).
129- .test-asan-template :
130- extends : .test-template
131- tags :
132- - docker
133- - linux
134- - x64
135- variables :
136- # Image defaults to POSIX (ASCII), set a compatible locale so UTF-8 tests that interact with the file system work.
137- # Check with 'locale -a' for available locales.
138- LC_ALL : " C.UTF-8"
112+ .test_jdks :
113+ << : *docker_linux_x64_android
114+ extends : .test_base
115+ # Overwrite script key to run through ASAN script and to run test task directly to avoid
116+ # running SpotBugs (build runs check runs SpotBugs tasks).
117+ # Note: Address sanitizer is only available on Linux runners (see script).
139118 script :
140- # Note: do not run check task as it includes SpotBugs.
141119 # Temporarily disable testing with Address Sanitizer until buildenv images are modernized, see #273
142120 # - ./scripts/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean :tests:objectbox-java-test:test
143121 - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean :tests:objectbox-java-test:test
144122
145123# Test oldest supported and a recent JDK.
146- # Note: can not run these in parallel using a matrix configuration as Gradle would step over itself.
147124test-jdk-8 :
148- extends : .test-asan-template
125+ extends : .test_jdks
149126 needs : ["test"]
150127 variables :
151128 TEST_JDK : 8
152129
153130# JDK 21 is the default of the current build image, so test the latest LTS JDK 25
154131test-jdk-25 :
155- extends : .test-asan-template
156- needs : ["test-jdk-8 "]
132+ extends : .test_jdks
133+ needs : ["test"]
157134 variables :
158135 TEST_JDK : 25
159136
160- test-jdk-x86 :
161- extends : .test-template
162- needs : ["test-windows"]
137+ test-macos :
138+ extends : .test_base
163139 tags :
164- - windows-jdk
140+ - jdk
141+ - mac
142+
143+ test-windows :
144+ extends : .test_base
145+ tags :
146+ - jdk
147+ - windows
165148 - x64
149+
150+ test-windows-jdk-x86 :
151+ extends : .test_base
152+ tags :
153+ - jdk-x86
154+ - windows
166155 variables :
167156 # TEST_WITH_JAVA_X86 makes objectbox-java-test use 32-bit java executable and therefore
168157 # 32-bit ObjectBox to run tests (see build.gradle file).
169158 # Note: assumes JAVA_HOME_X86 is set to 32-bit JDK path.
170159 TEST_WITH_JAVA_X86 : " true"
171- script : ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
172160
173161# Publish Maven artifacts to internal Maven repo
174162publish-maven-internal :
163+ << : *docker_linux_x64_android
175164 stage : publish-maven-internal
176- tags :
177- - docker
178- - linux
179- - x64
180165 rules :
181166 # Not when using release versions and not publishing a release to avoid duplicate artifacts
182167 # (GitLab would allow to upload duplicates for a release version)
@@ -191,36 +176,30 @@ publish-maven-internal:
191176 # Otherwise, only if no previous stages failed
192177 - when : on_success
193178 script :
194- - ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
179+ - ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishAllPublicationsToGitLabRepository
195180
196181# Publish Maven artifacts to public Maven Central repo
197182publish-maven-central :
183+ << : *docker_linux_x64_android
198184 stage : publish-maven-central
199- tags :
200- - docker
201- - linux
202- - x64
203185 rules :
204186 # Only if publishing a release, only if no previous stages failed
205187 - if : $OBX_PUBLISH_RELEASE == "true"
206188 when : on_success
207189 before_script :
208- - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library :* job $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..."
190+ - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java libraries to Maven Central :* job $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..."
209191 script :
210- # Note: supply internal repo as tests use native dependencies that might not be published , yet.
211- - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS $CENTRAL_PUBLISH_ARGS publishMavenJavaPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
192+ # Note: supply internal repo as tests use native dependencies that might not be available publicly , yet.
193+ - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS $CENTRAL_PUBLISH_ARGS publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository
212194 after_script :
213195 # Also runs on failure, so show CI_JOB_STATUS.
214- - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library :* *$CI_JOB_STATUS* for $CI_JOB_NAME"
196+ - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java libraries to Maven Central :* *$CI_JOB_STATUS* for $CI_JOB_NAME"
215197 - 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."
216198
217199# Create Java API docs archive
218200package-api-docs :
201+ << : *docker_linux_x64_android
219202 stage : package-api-docs
220- tags :
221- - docker
222- - linux
223- - x64
224203 rules :
225204 # Only if publishing a release, only if no previous stages failed
226205 - if : $OBX_PUBLISH_RELEASE == "true"
0 commit comments