gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

GitlabUpdateCommitStatus creates sometimes two builds in Gitlab

Open pgeorgiev333 opened this issue 9 years ago • 8 comments

Before submitting an issue I have first:

  • [x] read the documentation on the homepage
  • [x] searched for similar already existing issue

Issue

Incorrect update of the gitlab commit from jenkins multibranch pipeline

Context

  • Gitlab plugin version: 1.4.5
  • Gitlab version: GitLab Community Edition 8.11.2
  • Jenkins version: 2.4.7
  • Job type: Pipeline (Multi-Branch)

Logs & Traces

Problem description

I have a Gitlab Server configured with a webhook for push events that triggers a multibranch jenkins pipeline. The pipeline updates the gitlab commit status with just one build/stage. In most cases everything is ok but sometimes i see two builds in Gitlab that point to the same jenkins job and the overall state is IN PROGRESS although the job has passed

Here's the relevant part of the pipeline:

    gitlabBuilds(builds: ['Jenkins Pipeline']) {

        gitlabCommitStatus(name: 'Jenkins Pipeline') {

            executeTestsStageHelper(pipelineConfigurationJson)

        }
    }

Attach is a screenshot of one problematic commit: gitlabcommitstatus

Both builds in the screenshot refer to the same jenkins build. Another thing to note is that all commits are merges (i,e, this is the master branch and all commits are related to merging a branch in the master branch)

pgeorgiev333 avatar Feb 21 '17 12:02 pgeorgiev333

Can you give the correct version of the gitlab-plugin? There is no 3.05 version. 1.4.5 is the latest, released last week.

omehegan avatar Feb 21 '17 22:02 omehegan

Updated - it's 1.4.5

pgeorgiev333 avatar Feb 22 '17 09:02 pgeorgiev333

Hmm. I haven't seen this reported before. I did just notice something about your Pipeline code snippet - you don't need to use the gitlabBuilds block if there is only one stage within the build that is going to send status to GitLab. You can simply wrap that one step of the build in the gitlabCommitStatus block. This is how I do my builds. I wonder if this might be causing a problem. If I'm understanding your setup correctly, I would suggest you try removing the gitlabBuilds block and see if the problem goes away.

omehegan avatar Feb 23 '17 22:02 omehegan

I removed and i still see the issue. The difference is that now i do not see "running" on the overall commits page which is better. This is what i see now sometimes: gitlabcommitstatus2

pgeorgiev333 avatar Feb 24 '17 11:02 pgeorgiev333

@pgeorgiev333 did you ever resolve this?

omehegan avatar Jul 06 '17 04:07 omehegan

No. I switched to a different approach. Now i just use
updateGitlabCommitStatus(name: 'Build and Test', state: 'failed') and it works fine.

pgeorgiev333 avatar Jul 20 '17 09:07 pgeorgiev333

Do you think we need to update the documentation to make this clearer?

omehegan avatar Jul 21 '17 22:07 omehegan

Well, what i am using is just a different approach. Both should work

On Jul 22, 2017 01:32, "Owen Mehegan" [email protected] wrote:

Do you think we need to update the documentation to make this clearer?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jenkinsci/gitlab-plugin/issues/511#issuecomment-317127728, or mute the thread https://github.com/notifications/unsubscribe-auth/AQK4tuDnWlM1NSYsEXHQ39ZpbtML1_hgks5sQSb8gaJpZM4MHQIl .

pgeorgiev333 avatar Jul 22 '17 14:07 pgeorgiev333