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

update to v4 of gitlab api

Open ilushka85 opened this issue 7 years ago • 16 comments

ilushka85 avatar Jun 08 '18 02:06 ilushka85

I have this stackstrace if I launch a scan of my gitlab projects :

[Fri Jun 08 13:43:45 UTC 2018] Updating actions...
[Fri Jun 08 13:43:45 UTC 2018] Consulting GitLab Projects
ERROR: [Fri Jun 08 13:43:45 UTC 2018] Could not fetch sources from navigator argelbargel.jenkins.plugins.gitlab_branch_source.GitLabSCMNavigator@49df211a
java.util.NoSuchElementException: unknown id: visible
	at argelbargel.jenkins.plugins.gitlab_branch_source.api.GitLabProjectSelector.byId(GitLabProjectSelector.java:19)
	at argelbargel.jenkins.plugins.gitlab_branch_source.ProjectQuery.<init>(ProjectQuery.java:31)
	at argelbargel.jenkins.plugins.gitlab_branch_source.GroupProjectQuery.<init>(GroupProjectQuery.java:15)
	at argelbargel.jenkins.plugins.gitlab_branch_source.ProjectQuery.create(ProjectQuery.java:20)
	at argelbargel.jenkins.plugins.gitlab_branch_source.SourceVisitor.visitSources(SourceVisitor.java:25)
	at argelbargel.jenkins.plugins.gitlab_branch_source.GitLabSCMNavigator.visitSources(GitLabSCMNavigator.java:133)
	at jenkins.branch.OrganizationFolder.computeChildren(OrganizationFolder.java:458)
	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:276)
	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
	at jenkins.branch.OrganizationFolder$OrganizationScan.run(OrganizationFolder.java:910)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

ghost avatar Jun 08 '18 13:06 ghost

@jbomaileva we have the same issue.

tnijboer avatar Jun 27 '18 09:06 tnijboer

Any updates or progress on this? How could one help move this along? I believe this could resolve #83.

alexkoepke avatar Jun 27 '18 13:06 alexkoepke

GitLab v11 removed the v3 API. I tried your PR, seems to be working only when i remove my old project (old settings on version 0.6.x of this plugin) After recreating, the Jenkins project scan is working and all pipelines are created. But the webhooks arent registered in gitlab. Triggering the web hooks from old projects arent working too. However, testing the webhook from Gitlab returns HTTP 200, loggings are fine, but no builds are started.

Saving configuration triggers system webhook register which results in 403 forbidden responses

awilhelmer avatar Jun 29 '18 14:06 awilhelmer

Okay found all problems and it's working now.

  1. Add org.gitlab.api.models.GitlabProject in ClassFilter
  2. In GitLabSCMHead.java remove the suffix "t2" and "t3" ...

Last problem is registering System WebHook in GitlabAPI. Method private GitlabSystemHook registerSystemHook(String url) throws IOException. It always throws WARNING: could not register hook https://***/gitlab-scm/notify/***: error accessing gitlab-api: {"message":"403 Forbidden"}, don't know why, i created this hook manually in gitlab via curl ...

curl --request POST --header "PRIVATE-TOKEN: ***" "https://***/api/v4/hooks?url=https://***/gitlab-scm/notify/***&enable_ssl_verification=false"

awilhelmer avatar Jul 04 '18 08:07 awilhelmer

Hey @awilhelmer,

Thanks for looking into this! When you said, "Okay found all problems and it's working now." Were you referring to this pull request?

Also, when you said, "Last problem is registering System WebHook in GitlabAPI." Is that a new issue or did you resolve it?

Sorry for the confusion.

Cheers, Alex

alexkoepke avatar Jul 06 '18 13:07 alexkoepke

Hi @alexkoepke yes iam referring to this pull request and the two changes i made (The two points) locally. The System Webhook is still a problem and i think it's a problem in the Gitlab API v4 dependency...

awilhelmer avatar Jul 06 '18 13:07 awilhelmer

So, the plugin is not fully compatible with gitlab 11 yet ?

ghost avatar Jul 06 '18 14:07 ghost

It works. The System Webhook is to detect new or deleted branches. The Push webhook for projects works fine.

awilhelmer avatar Jul 08 '18 10:07 awilhelmer

can you share your commits?

tnijboer avatar Jul 09 '18 06:07 tnijboer

I resolved the issues noted in code that were part of my code for testing and also merged in the latest changed from master on here.

Additionally I began work on getting the note event trigger which is successfully working for merge requests but I cannot get it to trigger a job because it determines that the source code has not chnaged and will not trigger a build.

I would appreciate some help on this.

ilushka85 avatar Jul 11 '18 18:07 ilushka85

Thanks for working on this, @ilushka85! Commenting out the note event stuff, I was able to build this (findbugs complained about the unused assignment) and get it working again after a Gitlab upgrade

paulerickson avatar Jul 30 '18 18:07 paulerickson

@paulerickson do you think your fixes will get this PR to a passing state? @Argelbargel are you able to confirm?

alexkoepke avatar Aug 13 '18 13:08 alexkoepke

@alexkoepke okay, I opened #91 with Ilya's changes minus Notes, although I have not tested just yet. It would be great if someone else could test it too.

Push events still don't trigger for me, which I think is existing since 0.6.6.7

paulerickson avatar Aug 13 '18 16:08 paulerickson

I think this can be closed, since the v4 changes were incorporated in #91

paulerickson avatar Feb 11 '19 17:02 paulerickson

@paulerickson fantastic! Good to hear, I’ll test when I get the chance.

alexkoepke avatar Feb 11 '19 17:02 alexkoepke