Skip to content

fix(gitlab): enable skip-CI for merge requests#2405

Merged
zakisk merged 1 commit intotektoncd:mainfrom
theakshaypant:SRVKP-10440-fix-gitlab-skip-ci
Jan 30, 2026
Merged

fix(gitlab): enable skip-CI for merge requests#2405
zakisk merged 1 commit intotektoncd:mainfrom
theakshaypant:SRVKP-10440-fix-gitlab-skip-ci

Conversation

@theakshaypant
Copy link
Copy Markdown
Member

📝 Description of the Change

Skip-CI detection was not working for GitLab because the sinker only fetched commit info for pull_request events and SHAMessage was not populated during payload parsing.

👨🏻‍ Linked Jira

https://issues.redhat.com/browse/SRVKP-10440

🔗 Linked GitHub Issue

N/A

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable
Screenshot From 2026-01-21 13-28-46

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @theakshaypant, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug in the GitLab integration that prevented the skip-CI feature from functioning correctly for merge requests. The fix involves updating the event processing logic to recognize GitLab's "Merge Request" event type and ensuring that the commit message is properly extracted and stored, allowing the skip-CI command to be accurately detected and applied.

Highlights

  • GitLab Skip-CI Fix: Corrected an issue preventing skip-CI detection from working for GitLab merge requests.
  • Event Type Expansion: Extended the sinker to fetch commit information for both "pull_request" and "Merge Request" event types.
  • SHAMessage Population: Ensured the SHAMessage field is populated during GitLab payload parsing to make the commit message available for skip-CI checks.
  • Consistent Skip-CI Check: Modified the GitLab provider's GetCommitInfo to consistently use runevent.SHAMessage for skip-CI detection.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Jan 21, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 5a7a9b7 fix(gitlab): enable skip-CI for merge requests

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to enable [skip ci] functionality for GitLab merge requests. The changes to include the "Merge Request" event type are correct. However, there's an issue in how the commit message is being parsed from the GitLab payload. It's currently using the commit title instead of the full commit message, which will prevent [skip ci] from working if the directive is in the commit body. I've added a specific comment with a suggested fix for this.

processedEvent.SHA = gitEvent.ObjectAttributes.LastCommit.ID
processedEvent.SHAURL = gitEvent.ObjectAttributes.LastCommit.URL
processedEvent.SHATitle = gitEvent.ObjectAttributes.LastCommit.Title
processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Title
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The SHAMessage is being populated from LastCommit.Title, which only contains the subject line of the commit. To correctly detect [skip ci] directives, which may be in the commit body, you should use LastCommit.Message to get the full commit message. The GitLab merge request event payload includes the full message in this field.

Suggested change
processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Title
processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Message

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that by design?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is by design then test it explictely for it, and please explain with a comment why

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ask

is that by design?

Answer:

No — populating SHAMessage from LastCommit.Title is very likely not “by design” for skip-CI detection; it’s more a pragmatic workaround to ensure SHAMessage is non-empty for GitLab merge request events.

In GitLab, LastCommit.Title is only the subject line. Skip directives like [skip ci] / [ci skip] are commonly placed in the full commit message (subject or body). If we only store the title, we can miss valid skip directives present in the body, which defeats the purpose of fixing skip-CI for MRs.

Given the PR description (“SHAMessage was not populated during payload parsing”), the intended design seems to be:

  • SHATitle = subject/title
  • SHAMessage = full commit message (subject + body) used by provider.SkipCI(...)

So I’d recommend setting:

processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Message

(falling back to Title only if Message is empty/unavailable), to align with the semantics of SHAMessage and make skip-CI detection robust.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Implementation 🛠️

Implementation: Populate SHAMessage from the full GitLab commit message (with a safe fallback to the title) and add an inline comment explaining it is required for skip-CI detection which can be in the commit body.

Suggested change
processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Title
// Use the full commit message (not only the subject/title) so directives like `[skip ci]`
// present in the commit body can be detected reliably.
processedEvent.SHAMessage = strings.TrimSpace(gitEvent.ObjectAttributes.LastCommit.Message)
if processedEvent.SHAMessage == "" {
processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Title
}

See review comment here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ecaebd
Screenshot From 2026-01-22 09-06-27

@theakshaypant theakshaypant force-pushed the SRVKP-10440-fix-gitlab-skip-ci branch from 17f63bd to 6ecaebd Compare January 22, 2026 03:37
@theakshaypant
Copy link
Copy Markdown
Member Author

/retest

// For PULL REQUEST events: commit message needs to be fetched via API
// Get commit info for skip-CI detection (only if we successfully set up client above)
if s.event.EventType == "pull_request" && repo != nil {
if (s.event.EventType == "pull_request" || s.event.EventType == "Merge Request") && repo != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (s.event.EventType == "pull_request" || s.event.EventType == "Merge Request") && repo != nil {
if (s.event.EventType == "pull_request" || s.event.EventType == "Merge_Request") && repo != nil {

I think its Merge_Request

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked that it is Merge Request as fetched from the header. Attaching a payload header for reference.
We remove the " Hook" suffix in parse_payload.
image

processedEvent.SHA = gitEvent.ObjectAttributes.LastCommit.ID
processedEvent.SHAURL = gitEvent.ObjectAttributes.LastCommit.URL
processedEvent.SHATitle = gitEvent.ObjectAttributes.LastCommit.Title
processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Message
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may be both SHATitle + SHAMessage?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title is a substring (first line only) of the Message
image

Skip-CI detection was not working for GitLab because the
sinker only fetched commit info for pull_request events
and SHAMessage was not populated during payload parsing.

Jira: https://issues.redhat.com/browse/SRVKP-10440

Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
@theakshaypant theakshaypant force-pushed the SRVKP-10440-fix-gitlab-skip-ci branch from 6ecaebd to 5a7a9b7 Compare January 27, 2026 05:38
@theakshaypant
Copy link
Copy Markdown
Member Author

/review

@qodo-code-review
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Event Type Match

The skip-CI commit-info fetch now triggers for pull_request or Merge Request. Verify the event type values are consistent across providers (case/spacing) and won’t miss GitLab merge request events (or accidentally trigger on unexpected strings). Consider centralizing to constants/enums or normalizing before comparison.

// For PULL REQUEST events: commit message needs to be fetched via API
// Get commit info for skip-CI detection (only if we successfully set up client above)
if (s.event.EventType == "pull_request" || s.event.EventType == "Merge Request") && repo != nil {
	// Get commit info (including commit message) via API
	if err := s.vcx.GetCommitInfo(ctx, s.event); err != nil {
		return fmt.Errorf("could not get commit info: %w", err)
Skip-CI Source

HasSkipCommand is now computed from runevent.SHAMessage instead of branchinfo.Message. Confirm SHAMessage is always populated before calling GetCommitInfo (for all relevant GitLab event types) and that branchinfo.Message is not the only reliable source in some paths (e.g., when API returns message but payload doesn’t).

	if branchinfo.AuthoredDate != nil {
		runevent.SHAAuthorDate = *branchinfo.AuthoredDate
	}
	runevent.SHACommitterName = branchinfo.CommitterName
	runevent.SHACommitterEmail = branchinfo.CommitterEmail
	if branchinfo.CommittedDate != nil {
		runevent.SHACommitterDate = *branchinfo.CommittedDate
	}
}
runevent.HasSkipCommand = provider.SkipCI(runevent.SHAMessage)

return nil
Payload Coverage

Merge request payload parsing now sets SHAMessage from LastCommit.Message. Validate that this field is present for all MR webhook variants (and not empty/truncated), and ensure other GitLab events that rely on skip-CI detection also populate SHAMessage or fetch commit info accordingly.

case *gitlab.MergeEvent:
	// Organization:  event.GetRepo().GetOwner().GetLogin(),
	processedEvent.Sender = gitEvent.User.Username
	processedEvent.DefaultBranch = gitEvent.Project.DefaultBranch
	processedEvent.URL = gitEvent.Project.WebURL
	processedEvent.SHA = gitEvent.ObjectAttributes.LastCommit.ID
	processedEvent.SHAURL = gitEvent.ObjectAttributes.LastCommit.URL
	processedEvent.SHATitle = gitEvent.ObjectAttributes.LastCommit.Title
	processedEvent.SHAMessage = gitEvent.ObjectAttributes.LastCommit.Message
	processedEvent.HeadBranch = gitEvent.ObjectAttributes.SourceBranch
	processedEvent.BaseBranch = gitEvent.ObjectAttributes.TargetBranch
	processedEvent.HeadURL = gitEvent.ObjectAttributes.Source.WebURL

@zakisk zakisk merged commit 740ff2d into tektoncd:main Jan 30, 2026
15 of 17 checks passed
@theakshaypant theakshaypant deleted the SRVKP-10440-fix-gitlab-skip-ci branch January 30, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants