jenkinsci / jenkinsci/gitlab-plugin
addGitLabMRComment doesn't work with multi-branch pipeline
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 615
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 10
Description
## Issue
It appears that when I make a call to `addGitLabMRComment`, there is no request to GitLab made behind the scenes. The `gitlabCommitStatus` call *does* work perfectly though, so it isn't an issue with the connection to GitLab.
### Context
- **Gitlab plugin version**: 1.4.7
- **Gitlab version**: 8.14.5-ee
- **Jenkins version**: 2.66
- **Job type**: Multi-branch Pipeline
### Logs & Traces
Here is the relevant console output from the job:
```
[Pipeline] properties
[Pipeline] node
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] checkout
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] gitlabCommitStatus
[Pipeline] {
[Pipeline] sh
+ ./gradlew build
BUILD SUCCESSFUL
Total time: 6.042 secs
[Pipeline] }
[Pipeline] // gitlabCommitStatus
[Pipeline] addGitLabMRComment
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
```
And here is the output from the logger during the build:
```
Jul 20, 2017 1:08:43 PM FINE com.dabsquared.gitlabjenkins.webhook.build.PushBuildAction
Push: {
"object_kind" : "push",
"event_name" : "push",
"ref" : "refs/heads/test-branch",
"message" : null,
"user_id" : 1,
"project_id" : 1,
"project" : {
"name" : "test-project",
},
"commits" : [ {
"id" : "99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1",
"message" : "Trigger build\n",
"timestamp" : "2017-07-20T13:08:42-04:00",
} ],
"total_commits_count" : 1,
"repository" : {
"name" : "test-project",
}
}
Jul 20, 2017 1:08:43 PM FINE com.dabsquared.gitlabjenkins.webhook.build.PushBuildAction
Notify scmSourceOwner test-project about changes for http://gitlab.example.com/test-user/test-project.git
Jul 20, 2017 1:08:45 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Jul 20, 2017 1:08:45 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater addGitLabBranchBuild
Retrieving the gitlab project id from remote url http://gitlab.example.com/test-user/test-project.git
Jul 20, 2017 1:08:45 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Call GitLab:
HTTP method: GET
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/repository/commits/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
...
Jul 20, 2017 1:08:45 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/repository/commits/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
Status: 200 OK
...
Jul 20, 2017 1:08:45 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Call GitLab:
HTTP method: POST
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/statuses/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
...
Jul 20, 2017 1:08:45 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/statuses/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
Status: 201 Created
...
Jul 20, 2017 1:08:52 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Jul 20, 2017 1:08:52 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater addGitLabBranchBuild
Retrieving the gitlab project id from remote url http://gitlab.example.com/test-user/test-project.git
Jul 20, 2017 1:08:52 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Call GitLab:
HTTP method: GET
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/repository/commits/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
...
Jul 20, 2017 1:08:52 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/repository/commits/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
Status: 200 OK
...
Jul 20, 2017 1:08:52 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Call GitLab:
HTTP method: POST
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/statuses/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
...
Jul 20, 2017 1:08:52 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: http://gitlab.example.com/api/v3/projects/test-user%2Ftest-project/statuses/99df37fc9ddf25bd0ff0ed4d72fa4293ca9f91f1
Status: 201 Created
...
```
### Problem description
My Jenkinsfile looks something like this:
```groovy
#!/usr/bin/env groovy
def projectProperties = [
gitLabConnection('gitlab'),
]
properties(projectProperties)
try {
node() {
stage("Checkout") {
checkout scm
}
stage("Build") {
gitlabCommitStatus("build") {
sh "./gradlew build"
}
addGitLabMRComment comment: "Success!"
}
}
} catch (e) {
addGitLabMRComment comment: "Uh-oh!"
throw e
}
```
Contributor guide
Assessment
This issue has not been assessed yet.