Argelbargel / gitlab-branch-source-plugin

Jenkins-Plugin to create a multi-branch-project from gitlab
GNU General Public License v2.0
71 stars 44 forks source link

Migrate to v4 API #91

Closed paulerickson closed 5 years ago

paulerickson commented 6 years ago

See #80 — I took Ilya's changeset, removed in-progress Note stuff, tidied whitespace and rebased on upstream/master

paulerickson commented 6 years ago

@Argelbargel : this is working for me and I think @tuxx, so it would be super if you could take a look over when you can and see if is mergeworthy.

imduffy15 commented 6 years ago

Would love to see this its necessary since the gitlab 11 release.

imduffy15 commented 6 years ago

@paulerickson there looks to be issues with the private String projectUrl(GitLabProjectSelector selector, GitLabProjectVisibility visibility, String searchPattern) function within GitLabAPI.java.

It places in a /projects/[owned|starred|visible]/..... which is no longer valid in v4 it should be something like /projects?[owned=true|starred=true]

ref: https://docs.gitlab.com/ee/api/v3_to_v4.html and https://docs.gitlab.com/ee/api/projects.html

Project filters are no longer available as GET /projects/foo, but as GET /projects?foo=true instead !8962 GET /projects/visible & GET /projects/all are consolidated into GET /projects and can be used with or without authorization GET /projects/owned moved to GET /projects?owned=true GET /projects/starred moved to GET /projects?starred=true GET /projects returns all projects visible to current user, even if the user is not a member !9674 To get projects the user is a member of, use GET /projects?membership=true

alexsirbu commented 6 years ago

Tested with Jenkins ver. 2.121.3. Had to literally add all classes in hudson.remoting.ClassFilter file for it to work (including some subclasses), but afterwards it started working.

Sumit-Ahuja commented 6 years ago

@imduffy15 @alexsirbu Is there a PR or a commit with your changes? The original commit by @paulerickson doesn't really work, possibly due to the issues that you two have mentioned, but I suspect there might be more things that need fixing after I do what you two have already mentioned.

imduffy15 commented 6 years ago

@Sumit-Ahuja pushed mine to here https://github.com/imduffy15/gitlab-branch-source-plugin

alexsirbu commented 6 years ago

As I haven't really worked on this before, my solution of adding all the classes and some subclasses (the ones I saw in errors in various places) might not be the best solution for solving the issue (went with the temporary solution from here - https://jenkins.io/blog/2018/01/13/jep-200/). However, this is unrelated directly with this issue of moving to V4 as it's related to Jenkins version compatibility - and there are separate issues for it already.

alexkoepke commented 6 years ago

@Argelbargel Do you have an opinion regarding @alexsirbu's solution?

Sumit-Ahuja commented 6 years ago

@Sumit-Ahuja pushed mine to here https://github.com/imduffy15/gitlab-branch-source-plugin

I will try it out, thanks. Had a similar solution for the membership and owned things.

ghost commented 6 years ago

Do you have the "Don't trigger WIP Merge Request" feature working ? The filter seems to not be called in my local dev environnment.

paulerickson commented 6 years ago

@jbomaileva I haven't tested that myself, since I like building my PRs, but maybe someone else can weigh in.

FWIW, I use this beauty when I want to be selective of WIP status:

// All PRs go to test
stage('Deploy PR to Test') {
  when { changeRequest() }
  steps {…}
}

// Only non-WIP PRs go to beta
stage('Deploy PR to Beta') {
  when { allOf {
    changeRequest()
    expression { env.gitlabMergeRequestTitle ==~ /^(?i)(?!\[?WIP).*$/ } // Skip Work-In-Process PRs 
  } } 
  steps {…}
}
paulerickson commented 6 years ago

@Argelbargel any chance of merging this? I have been using this build in production since August without incident and folks are making changes against this now for lack of v4 stuff on master. Thanks!

makarek commented 5 years ago

Is there any fork/brach where we can use option Auto-Register Webhook

paulerickson commented 5 years ago

@makarek that's working fine for me with this branch

makarek commented 5 years ago

@paulerickson Cool I've build from your commit and everything is working so far. One question about webhook cuz currently plugin created it with SSL Verification Disabled, it there an easy way to change it ?

paulerickson commented 5 years ago

@makarek I get the same. Sorry, I don't know how to change it.

imduffy15 commented 5 years ago

@paulerickson @Argelbargel what is stopping this from being merged and released?

Argelbargel commented 5 years ago

Hi there, sorry for the long wait, but i've been quite busy with other things lately. I've just released 0.7.7-dev which incorporates the changes made by @paulerickson