@@ -34,11 +34,14 @@ stages:
3434
3535workflow :
3636 rules :
37- # Never create a pipeline when a tag is pushed (to simplify release checks in root build script)
37+ # Disable merge request pipelines https://docs.gitlab.com/ci/jobs/job_rules/#ci_pipeline_source-predefined-variable
38+ - if : $CI_PIPELINE_SOURCE == "merge_request_event"
39+ when : never
40+ # Never create a pipeline when a tag is pushed (to simplify version computation in root build script)
3841 - if : $CI_COMMIT_TAG
3942 when : never
40- # Otherwise, only create a pipeline when a branch is pushed
41- - if : $CI_PIPELINE_SOURCE == "push"
43+ # In all other cases, create a pipeline
44+ - when : always
4245
4346test :
4447 stage : test
@@ -134,17 +137,17 @@ publish-maven-internal:
134137 stage : publish-maven-internal
135138 tags : [ docker, x64 ]
136139 rules :
137- # Not from main branch, doing so may duplicate release artifacts (uploaded from publish branch)
140+ # Not for main branch, doing so may duplicate release artifacts (uploaded from publish branch)
138141 - if : $CI_COMMIT_BRANCH == "main"
139142 when : never
140143 # Not if triggered by upstream project to save on disk space
141144 - if : $CI_PIPELINE_SOURCE == "pipeline"
142145 when : never
143- # Not from scheduled pipelines to save on disk space
146+ # Not for scheduled pipelines to save on disk space
144147 - if : $CI_PIPELINE_SOURCE == "schedule"
145148 when : never
146- # Otherwise, only on push to branch
147- - if : $CI_PIPELINE_SOURCE == "push"
149+ # Otherwise, only if no previous stages failed
150+ - when : on_success
148151 script :
149152 - ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
150153
@@ -153,8 +156,9 @@ publish-maven-central:
153156 stage : publish-maven-central
154157 tags : [ docker, x64 ]
155158 rules :
156- # Only on publish branch
159+ # Only on publish branch, only if no previous stages failed
157160 - if : $CI_COMMIT_BRANCH == "publish"
161+ when : on_success
158162 before_script :
159163 - 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)..."
160164 script :
@@ -170,8 +174,9 @@ package-api-docs:
170174 stage : package-api-docs
171175 tags : [ docker, x64 ]
172176 rules :
173- # Only on publish branch
177+ # Only on publish branch, only if no previous stages failed
174178 - if : $CI_COMMIT_BRANCH == "publish"
179+ when : on_success
175180 script :
176181 - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS :objectbox-java:packageJavadocForWeb
177182 after_script :
@@ -187,8 +192,8 @@ trigger-plugin:
187192 # Do not trigger publishing of plugin
188193 - if : $CI_COMMIT_BRANCH == "publish"
189194 when : never
190- # Otherwise, only on push to branch (also set allow_failure in case branch does not exist downstream)
191- - if : $CI_PIPELINE_SOURCE == "push"
195+ # Otherwise, only if no previous stages failed. Also set allow_failure in case branch does not exist downstream.
196+ - when : on_success
192197 inherit :
193198 variables : false
194199 allow_failure : true # Branch might not exist in plugin project
0 commit comments