jenkinsci / jenkinsci/gitlab-plugin

Reports status to wrong commit when receiving two pushes within short timeframe

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

Description

### Context
- **Gitlab plugin version**: 1.4.5
- **Gitlab version**: 9.0.2-ee
- **Jenkins version**: 1.609.3
- **Job type**: Freestyle

### Logs & Traces

Please see https://gist.github.com/meeee/4f939434812c75d42ba127b6bed99b82

### Problem description

I'm using the Gitlab API to automatically create a branch and make a commit on the branch, which both happens within a few seconds (< 3 seconds).

As visible in the logs, Jenkins receives a hook for branch creation (commit A, 5bb2a383) and a hook for the push on the branch (commit B, 084ae98c), 5 seconds apart. It then continues to run the job for commit B, but posts statuses for commit A. Here's a summary of the logs, written from the perspective of Jenkins:

* Receives push for branch creation (commit A)
* Creates status for commit A (pending)
* Receives push for commit adding .gitlab-ci.yml (commit B)
* Creates status for commit B (pending)
* Runs Jenkins job with commit B, but thinks it's running commit A
* Loads Commit information for commit A
* Creates status for commit A (running)
* Loads commit information for commit A
* Creates status for Commit A (success), although Jenkins tested commit B
* Commit B stays in status 'pending' forever

I would have expected Jenkins to both test commit A and commit B after another and push the statuses for each build to correct commit in Gitlab.

Waiting 10 seconds between creating the branch and creating the commit works around the problem.

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.