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

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

Open pgeorgiev333 opened this issue 9 years ago • 28 comments

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.

pgeorgiev333 avatar Mar 13 '17 09:03 pgeorgiev333

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.

chizmeeple avatar Mar 14 '17 11:03 chizmeeple

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

chizmeeple avatar Mar 14 '17 12:03 chizmeeple

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

chizmeeple avatar Mar 14 '17 12:03 chizmeeple

~~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.

0megam avatar Mar 15 '17 15:03 0megam

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.

pgeorgiev333 avatar Mar 16 '17 07:03 pgeorgiev333

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. :-/

pcornelissen avatar Mar 20 '17 05:03 pcornelissen

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

marius-balteanu avatar Mar 31 '17 12:03 marius-balteanu

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

marius-balteanu avatar Apr 01 '17 11:04 marius-balteanu

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

hubermi avatar Apr 12 '17 07:04 hubermi

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

0megam avatar Apr 24 '17 07:04 0megam

@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.

omehegan avatar Apr 24 '17 21:04 omehegan

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

raynigon avatar Apr 26 '17 12:04 raynigon

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

omehegan avatar May 03 '17 23:05 omehegan

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

tsutsarin-fuib avatar May 04 '17 07:05 tsutsarin-fuib

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

sbrassely avatar May 04 '17 07:05 sbrassely

Weirdly in the previous comment:

  • https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/util/CommitStatusUpdater.java#L129 (incorrectly) linked to
  • https://github.com/jenkinsci/gitlab-plugin/issues/url

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

chizmeeple avatar May 04 '17 09:05 chizmeeple

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.

omehegan avatar May 18 '17 00:05 omehegan

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.

lalmeras avatar May 18 '17 03:05 lalmeras

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

mreichel avatar May 29 '17 09:05 mreichel

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.

neurolabs avatar Jun 07 '17 10:06 neurolabs