Add failed-pipeline trigger and enrich pipeline event metadata#1919
Open
damjanek wants to merge 1 commit into
Open
Add failed-pipeline trigger and enrich pipeline event metadata#1919damjanek wants to merge 1 commit into
damjanek wants to merge 1 commit into
Conversation
Make pipeline (CI) event handling useful beyond the previous
"build only on successful pipelines" behaviour.
Trigger:
- Add a "Build on failed pipeline events" option
(triggerOnFailedPipelineEvent) alongside the existing successful-pipeline
option, so failed pipelines no longer go unnoticed.
PipelineHookTriggerHandlerFactory now derives the set of allowed pipeline
states from both flags.
Merge request resolution:
- Add GitLabClient#getCommitMergeRequests(projectId, sha), backed by the
GitLab v3/v4 "/repository/commits/{sha}/merge_requests" endpoint, so a
pipeline event can be associated with its merge request. The handler uses
this to resolve the MR title/iid/id and to derive the correct target
branch (MR target branch, else project default branch, else the ref).
Build cause / environment variables:
- Expose richer pipeline metadata as build environment variables: pipeline
id/iid/source/url, commit message/title/author name/email/url, and
project web URL / path-with-namespace.
- Populate the pipeline CauseData from the project and commit payloads and
use the source branch for branch/sourceBranch.
Webhook model:
- Add the payload fields required by the above: PipelineHook.commit and
mergeRequest, Commit.title, Project.gitSshUrl / gitHttpUrl, and
PipelineEventObjectAttributes.iid / source / url.
Tests:
- Cover triggering on failed pipeline events and that failed events are
ignored when the option is disabled; add getCommitMergeRequests stubs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Makes GitLab pipeline (CI) event handling useful beyond "build only on success":
no longer go unnoticed. The trigger now derives its allowed pipeline states
from the success and failed flags independently.
getCommitMergeRequests(projectId, sha)(GitLab v3/v4
/repository/commits/{sha}/merge_requests) so a pipeline eventis associated with its MR; used to resolve MR title/iid/id and the target
branch (MR target → project default branch → ref).
message/title/author name/email/url, and project web URL / path-with-namespace.
Testing
Automated — added to
PipelineHookTriggerHandlerImplTest:pipeline_build_on_failed_event— afailedevent triggers when enabledpipeline_build_ignores_failed_when_not_configured—failedignored when disabledResult:
Tests run: 4, Failures: 0, Errors: 0(Maven 3.9.9 / JDK 21);hpipackages cleanly.Manual — deployed the built
.hpiagainst a live GitLab:gitlabPipeline*,gitlabCommit*,gitlabProject*env vars populated.The model/API additions have no dedicated unit tests as they are plain
payload/proxy mappings exercised by the above; let me know if you'd like the env-var mapping unit-tested.
Submitter checklist