jenkinsci / jenkinsci/gitlab-plugin

gitlabCommitStatus can create statuses on the wrong ref

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

Description

### Before submitting an issue I have first:

## Issue

When using `gitlabCommitStatus` to update the status of a SHA, the wrong ref (e.g. branch) can be used, causing the status to be stuck in pending.

### Context
- **Gitlab plugin version**: 1.5.11
- **Gitlab version**: 11.9.6-ee
- **Jenkins version**: 2.164.1
- **Job type**: Pipeline

### Logs & Traces

_Please include any relevant log that could serve to better understand the source of your issue_
For Jenkins Gitlab Plugin logs, follow instruction in [User Support section](https://github.com/jenkinsci/gitlab-plugin#user-support).
For Gitlab logs, ask an administrator to provide you the relevant Gitlab logs.

### Problem description

_Describe your problem in a meaningful way_:

I've setup a standard Pipeline build where a stage reliably takes over 5 minutes, for example

```
stage ("Run Unit Tests"){
gitlabCommitStatus("Run Unit Tests") {
// To simulate a long running process
sh("sleep 300")
}
}
```

If someone creates a new branch that comes before the current running branch (e.g. `a-branch` comes before `master`) with the same SHA, the `success` state is reported for the new branch instead of the running branch. This leaves the original branch in a `pending` state indefinitely.

How to reproduce:

1. Push a new SHA to `master`
1. Wait for a build step to start.
1. `git checkout -b a-branch && git push origin a-branch`
1. Notice in Gitlab that all subsequent statuses will be applied to `a-branch` instead of `master`, and that `master` will remain in a pending state.

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.