-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for GitLabAPI V4 while keeping support for V3 #614
Conversation
This commit is the simplest change which seems to suffice to move the Jenkins plugin to APIv4. [The docs][api-docs] regarding the move from v3 to v4 and going through most of the source, suggest that is the only change too. To summerize, the path changed from `api/v3` to `api/v4` and when referencing merge requests in paths the IID is now needed instead of the ID. Tests are passing, but in this case I feel like that doesn't suggest anything and this branch will undergo some manual testing soon. [api-docs]: https://docs.gitlab.com/ce/api/v3_to_v4.html
# Conflicts: # src/main/java/com/dabsquared/gitlabjenkins/gitlab/api/impl/V3GitLabClientProxy.java
@Argelbargel that is a very good approach! Can't wait to see it released. |
@bikebilly: if you're willing to install the plugin manually, you can try out a development-release from here: https://github.com/Argelbargel/gitlab-plugin/releases/gitlab-v4-SNAPSHOT/ |
# Conflicts: # src/main/java/com/dabsquared/gitlabjenkins/gitlab/api/impl/V3GitLabClientProxy.java # src/test/java/com/dabsquared/gitlabjenkins/testing/gitlab/rule/GitLabRule.java # src/test/java/com/dabsquared/gitlabjenkins/testing/integration/GitLabIT.java
@Argelbargel this is great, thanks for taking the initiative to extend the original feature PR! For the record, I understand that GitLab has decided they are not quite ready to deprecate the v3 API, so it will still work at least in the 10.0 release. |
That's my understanding too - so we have enough time for a thorough review and perhaps might find some users to try out dev-snapshots in real-world environments. |
@omehegan API v3 have been deprecated back in GitLab 9.0, but until actual removal they will continue to work as usual. Removal was discussed to happen in 10.0, but we decided to postpone so users have more time to update to the new version of the plugin (and other reasons unrelated to Jenkins). Anyone interested can follow the plan at https://gitlab.com/gitlab-org/gitlab-ce/issues/36819. |
# Conflicts: # src/main/java/com/dabsquared/gitlabjenkins/gitlab/api/impl/V3GitLabClientProxy.java # src/test/java/com/dabsquared/gitlabjenkins/testing/gitlab/rule/GitLabRule.java # src/test/java/com/dabsquared/gitlabjenkins/testing/integration/GitLabIT.java
Has this any chance of being accepted anytime soon? At the current pace of changes in master, the effort of merging and fixing conflicts kinda nears the point where it'll be easier to start over when support for v4 is really required. No offense meant, it's partly my own fault, but nonetheless... |
@Argelbargel @omehegan if you don't have any strong reasons for not merging it, please do as soon as possible. We decided to postpone removal of API v3 mainly because of this plugin, and if you wait to merge since API are still available in the next version, we are in a deadlock. We have strong pressure on removing API v3, so I kindly ask you if we can move forward here. Please let us know if we can be of any help in the process. Thanks. |
The pr looks pretty good to me. @Argelbargel could you look into the merge conflicts? |
@mreichel: i did. that was the cause for my comment - as both mine and the current merges in master heavily change/rename the same classes i got a litte frustrated ;-) I'll look further into it, it seems many of the conflicts occur because of changes in intendation/import ordering and such funny little things... is there a ruleset for formating for this project which contributors can use? |
@Argelbargel Here are some screenshots: Since the gitlab update to 10.x the builds don't show up anymore, thought the (The yellow minion is our jenkins user) Jenkins builds did never show up in 'jobs', so i guess it's ok. Unfortunately I can not post a screenshot with working gitlab-plugin, because downgrading gitlab broke something i can't remember anymore(sorry). That's all i can provide for now, at least till tomorrow. |
Okay, just to get this right: the builds do not show up with the currently released version too? So while a problem it's not a regression caused by the changes in this pull-request? |
Yes, since we updated gitlab to 10.x we do not see any builds. I thought the reason for this was the removed support for APIv3. |
@Alexxtheonly in GitLab 10.x we still support APIv3 (even if deprecated in favor of APIv4), so that is unlikely to be the problem: https://about.gitlab.com/2017/09/22/gitlab-10-0-released/#api-v3. We removed CI API v1 (used by GitLab Runner < 9.0), but I don't think the plugin is relying on that. |
@bikebilly: no, as far as i know, the plugin does not use the CI API. |
@Argelbargel can you squash your changes? I will release another snapshot shortly. |
http://repo.jenkins-ci.org/snapshots/org/jenkins-ci/plugins/gitlab-plugin/1.4.9-SNAPSHOT/gitlab-plugin-1.4.9-20171018.215942-2.hpi has been released with the latest changes in this branch. Please test! |
Did some further digging, our issues have nothing to do with this pull request. I'm sorry for any inconvenience caused. The issue for us is, when configuring 'Gitlab host URL' it fails when Currently I don't know what exactly is causing this, but quick searches suggest it is related to our certificate (not self signed). With http:// the connection check is successful, however, gitlab reports 301 as status.
Again sorry for any inconvenience caused. I will come back to report my test results regarding this pull request when I've resolved the other issue. |
@omehegan: will do - or couldn't you just use the "squash and merge option" when merging this into master (click on the down-arrow right to "Merge pull request")? Should i leave the travis-scripts in here or will you update the jenkins build to execute the integration-tests? |
With help from @Argelbargel and a lot of trial and error, jenkins and gitlab are obeying my commands again :) My tests in regards to this PR were all successful. I can confirm it works without any issues. |
@Argelbargel oh I've never tried to squash-merge in GitHub, but OK! I can get Jenkins to run the additional tests (I think), let me give that a try. @christ66 @mreichel would either of you like to give this PR a last check before we merge it? |
@omehegan: that would be great. Don't think running the tests against Gitlab 8.x is that important but integrating against 9.x and upwards would be good to catch the differences to come... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last changes mainly affect the build process. I can't run the integration test profile on OSX or Linux because the Docker plugin is giving me some trouble. But I don't think that is a show stopper.
Hi guys, any feedback on this? There is a really long weekend coming up here in germany, so I'll have time to put some work into this if required. |
@Argelbargel it sounds like @mreichel is happy, I didn't realize that the only real changes since her review and @christ66's were with the Travis build stuff. So I think we should go ahead and merge, and release this as a one-change release. I will do that this week, and we should ask GitLab to encourage their users to upgrade and test after we do that, just because they have the most frequent direct contact with users of this plugin. |
OK, plugin version 1.5.0 has been released with only this change. It should be available in the update center within a few hours. Thanks everyone for your help getting this feature completed! If you discover any potential problems, please open new issues for them. |
Thanks everyone for your great job! We'll give the good news to our customers so they can upgrade to the new version. Is APIv4 the default, or do you need to force them in the configuration? I'm wondering if upgrading the plugin is enough to test APIv4 calls, as we still support both versions. |
@bikebilly : the default setting is "autodetect" which uses v3 when available and switches to v4 otherwise. The result of the autodetection is cached so it might be neccessary to restart jenkins after an upgrade to gitlab 11. Or we could easily change the order in which the apis are detected. I'll provide an implementaiton of the autodetection which will not require a jenkins restart as soon as i can get my hands on a docker-image for gitlab 11 from https://github.com/sameersbn/docker-gitlab/releases - for now i chose this, admittedly a bit cumbersome variant, as it has the least possibility to break older setups. |
Oh I didn't see it coming early, sorry. That could be a problem as all the users that upgrade to the new plugin version will not test the APIv4 implementation (as we still support APIv3). This will not allow "involuntary" testing, but maybe it is a safer option. What about this plan:
It seems to me the best approach to avoid problems, and we actually don't already know when GitLab 11.0 will be out. Also, it is not strictly related to APIv3 removal, that can happen even later if it is really a necessity (but hopefully it will not be the case). |
I'm waiting to test this. I've upgraded the plugin to 1.5.0 already, how can I force it to use v4 in a multibranch pipeline job using the Jenkinsfile? |
@bikebilly: good plan. and i'll try to re-implement the autodetection without requiring a restart right away ;-) @stefanandres: you have to select it in the advanced-section for the gitlab-connection configuration in the system-wide-configuration |
Ah thanks, in the general settings. I can confirm that the v4 works as good as v3. Though personally I still have the bug the runtime-status changes are not sent to gitlab. (that is something that worked with 1.3.0 or so and I've changed nothing in the configuration so far, as far as I know) (Jenkinsfile: https://gist.github.com/stefanandres/7468a46b02267736a0cbb39c0622d356) |
@stefanandres You need to wrap your code inside a gitlabBuilds(builds: ['build']) {
gitlabCommitStatus('build') {
stage name: 'Pre-Cleanup'
deleteDir()
[…]
}
}
} This is likely considered off-topic for this PR though so you should probably open a separate issue or ask somewhere else (no idea where). |
@Argelbargel sounds very good to me. I already asked if we can select some customers for the first phase of the test for APIv4 support. |
@bikebilly: i've changed the order in which the apis are detected and improved the autodetection. See #650 ;-) |
This is an enhancement of PR #596 which adds support for gitlab-api v4 while keeping support for v3
(as i forked jenkins/gitlab-plugin i could not find a simple way to add to @ZJvandeWeg 's PR).
GitLabConnectionConfig has a new configuration option "API-Level" in the advanced configuration section where you can switch between v3 and v4. Default is "autodetect" which tries to determine which api-endpoint is available (v3 is preferred for now). The result of the autodetection is cached after the first request to the server.
Additionally, i've tried to change the name of the classes so that the class-names correspond with the names of the getters and variables, thus GitLabApi is now called GitLabClient.
This is just some fancy code to switch the interface-definitions used to create a gitlab-rest-client. i'm not sure if switching between apis will work for existing jobs which do not have both the id and iid of merge-requests stored somewhere - could be that we have to change other parts to build a seamless upgrade path to v4.