jenkinsci / jenkinsci/gitlab-plugin

gitlabMergeRequestState is not populated when triggered via webhook by a note

Open
#1,823 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.4k
Forks
615
Avg merge
4h 32m
Merged PRs (30d)
10

Description

Summary:
When a Jenkins job is triggered by a GitLab Note webhook on a Merge Request, the environment variable gitlabMergeRequestState is not populated, even though the webhook payload includes the merge_request.state field.
This causes pipelines triggered by MR comments to lose context about the MR’s current state (opened, merged, closed), which breaks consistency with normal Merge Request event triggers.

### What Operating System are you using (both controller, and any agents involved in the problem)?

N/A

### Reproduction steps

1. In GitLab, create a Merge Request.
2. Add a comment (note) on the MR that triggers a Jenkins pipeline (via the GitLab plugin).
3. In the Jenkinsfile, add:

```
pipeline {
agent any
stages {
stage('debug') {
steps {
sh 'env | grep gitlabMergeRequest'
}
}
}
}
```

### Expected Results

gitlabMergeRequestState is missing

### Actual Results

gitlabMergeRequestIid, gitlabSourceBranch, and gitlabTargetBranch is present but gitlabMergeRequestState is missing

### Anything else?

_No response_

### Are you interested in contributing a fix?

I think the change needs added here to include the merge request state

https://github.com/jenkinsci/gitlab-plugin/blob/df99f2347c438395f91cbaef613f5fadc34ff7da/src/main/java/com/dabsquared/gitlabjenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java#L70

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.