Gitlab-plugin: Build result sent to Pipeline library repo instead of project repo after upgrading workflow-multibranch-plugin to 2.13

Created on 13 Mar 2017  路  28Comments  路  Source: jenkinsci/gitlab-plugin

Issue

https://issues.jenkins-ci.org/browse/JENKINS-42535

This is the issue i submitted for the multibranch plugin. Unfortunately no one has commented on it.

Context

  • Gitlab plugin version: 1.4.5
  • Gitlab version: 8.11.2 (community edition)
  • Jenkins version: 2.32.3
  • Job type: Multi-Branch Pipeline

Logs & Traces

Retrieving the gitlab project id from remote url https://gitlab server 1/myusername/pipeline-shared-library.git
Mar 07, 2017 1:38:49 PM FINE com.dabsquared.gitlabjenkins.util.CommitStatusUpdater
Project (myusername/pipeline-shared-library) and commit (af88dcda9dc5e6a2eb06c563e6ec410b191893d6) combination not found

Problem description

This is the link to the suspected pipeline defect:

https://issues.jenkins-ci.org/browse/JENKINS-33273

This defect makes some changes to the changelog so this may affect the gitlab plugin. Not sure where the fix should be...

And This is a copy paste from the pipeline defect:

I have a setup where a gitlab commit will trigger via webhook a jenkins Multi-Branch pipeline. The pipeline uses the CPS library, i.e. the Jenkinsfile starts like this:

@Library('mylib@master')
import ....
import ....

When the pipeline is triggered it checks out the library from a git repo. So we have several checkouts:
Checkout the repository that contains the code to build (the webhook trigger) to read the Jenkinsfile (gitlab server 1)
After the Jenkinsfile is parsed the repository that contains the library is checked out (gitlab server 2)
Inside the pipeline i checkout the main repository one more time to build it (gitlab server 1)
With Pipeline: Multibranch vesion 2.12 the gitlab commit status was updated correctly - i have a code similar to this in the pipeline:
gitlabCommitStatus(name: 'Build Repository') {
......
}

However after i updated Pipeline: Multibranch to version 2.13 and restarted jenkins the commits in GitLab are no longer updated. In the jenkins logs i see this:

Retrieving the gitlab project id from remote url https://gitlab server 1/myusername/pipeline-shared-library.git
Mar 07, 2017 1:38:49 PM FINE com.dabsquared.gitlabjenkins.util.CommitStatusUpdater
Project (myusername/pipeline-shared-library) and commit (af88dcda9dc5e6a2eb06c563e6ec410b191893d6) combination not found

'pipeline-shared-library.git' is the repo that contains the pipeline cps library, but it is located on the gitlab server 2 not the gitlab server 1 (that's why the repo + commit combinations cannot be found in the message above). Just to note that af88dcda9dc5e6a2eb06c563e6ec410b191893d6 is the last commit id in the pipeline-shared-library.git repo.
Teh main problem is that this is the wrong commit/repo to update ....
I think this is somehow related to Jenkins-33273 but i'm not sure.

bug

Most helpful comment

Thanks. Do you have any idea when a new release will be published?

All 28 comments

I believe we are seeing similar behaviour in our setup.

We had working jenkins->gitlab notifications for build.commit status.

This week we've been trying to work out why we're not seeing any updates, and looking at the logs we are (also) seeing:

POST /api/v3/projects/芦global library禄/statuses/芦Commit SHA禄

We've tried scoping at all various levels.
We've tried the newer pipeline { ... } syntax.

Nothing.

The only time we see the _correct_ request in the gitlab logs is if we completely remove the:

@Library('Acme') _

statement from the Jenkinsfile.

We're seeing this with 2.13 and 2.14 versions of "Pipeline: Multibranch" (https://plugins.jenkins.io/workflow-multibranch).
Downgrading to 2.12 is non-trivial (i.e. not offered by the UI) so we've been unable to test this downgrade.

Downgraded to 2.12.
Correct URI seen in gitlab's nginx logs.

cd /var/lib/jenkins/plugins/

# remove existing
mkdir ~/plugins
sudo mv workflow-multibranch* ~/plugins

# grab older plugin
sudo -u jenkins curl -OL http://updates.jenkins-ci.org/download/plugins/workflow-multibranch/2.12/workflow-multibranch.hpi
# then restart jenkins

Downgrade doesn't help. Still having same issue. gitLab plugin trying to update commit in @Library git repo. GitLab plugin 1.4.5, Pipeline Multibranch 2.12
Update: Downgrading works.

Downgrading works for me. However after doing this my git changelog got messed up (each build reports some of the old commits as new changes...) and i just delete the mulribranch pipeline and re-created it. But with Multibranch 2.12 my gitlab is updated correctly.

I have the same problem. I'm also using the multibranch jenkinspipeline plugin and in the production log I see things like:

Started GET "/api/v3/projects/kulinariweb%2Fjenkinspipeline/repository/commits/dfce57344e5fdae6f0f9c7caf00ecXXXXXX4a" for 88.XX.YY.136 at 2017-03-20 06:30:44 +0100
Started POST "/api/v3/projects/kulinariweb%2Fjenkinspipeline/statuses/dfce57344e5fdae6f0f9c7caf00ecb9d0XXXXXXXXXX4a" for 88.XX.YY.136 at 2017-03-20 06:30:44 +0100

I have found no way to provide the correct gitlab project somewhere. I tried
properties([gitLabConnection('gitlab'), [$class: 'GitlabLogoProperty', repositoryName: "${params.GITLAB_PROJECT}/${params.GITLAB_NAME}"]])

But I'm having trouble to define the project and name globally so I don't have to pass it around everywhere. :-/

Same problem here using Jenkins Multibranch 2.14 and GitLab plugin 1.4.5.

I can confirm that downgrading the Multibranch plugin to 2.12 fixes the issue.

Same problem here with Multibranch 2.14 and Gitlab plugin 1.4.5

Using a shared library that is configured to load implicit in jenkins global configuration

It's impossible to use latest Blue Ocean with gitlab and multibranch plugins. It requires Multibranch 2.14 or later ;``(

@stephenc is there any chance you could take a look at this? I really don't know anything about the interaction between our plugin and workflow-multibranch-plugin. Just wondering if you can think of an obvious reason why this would be broken when multibranch-plugin is updated.

Same problem here with Multibranch 2.14 and Gitlab plugin 1.4.5

Using a shared library that is configured to load implicit in jenkins global configuration

Is this only affecting people who use the @Library function of Pipeline?

@omegarus Yes. I'm using @Library function of Pipeline only and also affected.
Same Multibranch 2.14 and Gitlab plugin 1.4.5 versions.

I'm also facing this issue with implicit load of library.
When looking at the https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/util/CommitStatusUpdater.java#L129 and build file (build.xml), we can see there's more than one BuildData tags (hudson.plugins.git.util.BuildData). build.getAction() return the first instance of build data....
Maybe the problem come's here....

Edited : link corrected

Weirdly in the previous comment:

Just in case you're clicking and wondering where the destination vanished to.

Per Jesse's comment in https://issues.jenkins-ci.org/browse/JENKINS-42535, it seems like we need to switch to looking up the revision using SCMRevisionAction rather than BuildData. @mreichel or @colourmeamused maybe you would like to look into this? Or I may try to do so for fun this week.

Here is a quick and very dirty fix that works for me: https://github.com/lalmeras/gitlab-plugin/commit/56809f324e3017d1fdc8c297cacc4144898554bf

My problem is that my way to lookup repository's url is not consistent with SHA lookup, but maybe I missed clever way to fix it with SCMRevisionAction.

@omehegan did you look into this? Otherwise I could start this week...

Is anyone working on this? I'm eagerly waiting for a fix. This blocks me from using blue ocean, as well as from freely updating jenkins.

Thanks. Do you have any idea when a new release will be published?

Could you be so kind and release a new version including this fix? Or communicate when there will be a new release?

Yes please release this! We've been struggling with this bug at work for some weeks now. It's frustrating when it appears to have been debugged and resolved, but not released (in close to three weeks now).

Indeed, please release a new version of the plugin.

This was released today in version 1.4.6 of the plugin.

Not yet accessible in update manager, also broken link on https://wiki.jenkins.io/display/JENKINS/GitLab+Plugin (to 1.4.6)

@neurolabs there was a wider issue with the Jenkins update center last night, it has since been resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ffrddrll picture ffrddrll  路  6Comments

amarruedo picture amarruedo  路  5Comments

samsieber picture samsieber  路  5Comments

almozavr picture almozavr  路  6Comments

jkdeveyra picture jkdeveyra  路  4Comments