Repository: buildbot/buildbot

Issue:
GitLab API v3 is removed from gitlab.com
Buildbot currently uses v3 of the Gitlab API, which has been deprecated for some time already and is now in the process of being removed. See https://gitlab.com/gitlab-org/gitlab-ce/issues/36819 for more details.


Discussion:
I think probably a sed s/v3/v4/ will do the job (look like there are 3 or 4 lines affected in the code)

https://github.com/buildbot/buildbot/blob/master/master/buildbot/reporters/gitlab.py#L94

Would you like to make a PR about it?

Resolving patch:
diff --git a/master/buildbot/reporters/gitlab.py b/master/buildbot/reporters/gitlab.py
--- a/master/buildbot/reporters/gitlab.py
+++ b/master/buildbot/reporters/gitlab.py
@@ -89,7 +89,7 @@ def createStatus(self,
         if context is not None:
             payload['name'] = context
 
-        return self._http.post('/api/v3/projects/%d/statuses/%s' % (
+        return self._http.post('/api/v4/projects/%d/statuses/%s' % (
             project_id, sha),
             json=payload)
 
@@ -106,7 +106,7 @@ def getProjectId(self, sourcestamp):
         project_full_name = urlquote_plus(project_full_name)
 
         if project_full_name not in self.project_ids:
-            response = yield self._http.get('/api/v3/projects/%s' % (project_full_name))
+            response = yield self._http.get('/api/v4/projects/%s' % (project_full_name))
             proj = yield response.json()
             if response.code not in (200, ):
                 log.msg(
diff --git a/master/buildbot/www/oauth2.py b/master/buildbot/www/oauth2.py
--- a/master/buildbot/www/oauth2.py
+++ b/master/buildbot/www/oauth2.py
@@ -358,7 +358,7 @@ def __init__(self, instanceUri, clientId, clientSecret, **kwargs):
         uri = instanceUri.rstrip("/")
         self.authUri = "%s/oauth/authorize" % uri
         self.tokenUri = "%s/oauth/token" % uri
-        self.resourceEndpoint = "%s/api/v3" % uri
+        self.resourceEndpoint = "%s/api/v4" % uri
         super(GitLabAuth, self).__init__(clientId, clientSecret, **kwargs)
 
     def getUserInfoFromOAuthClient(self, c):


Test patch:
diff --git a/master/buildbot/test/unit/test_reporter_gitlab.py b/master/buildbot/test/unit/test_reporter_gitlab.py
--- a/master/buildbot/test/unit/test_reporter_gitlab.py
+++ b/master/buildbot/test/unit/test_reporter_gitlab.py
@@ -68,26 +68,26 @@ def test_basic(self):
         # we make sure proper calls to txrequests have been made
         self._http.expect(
             'get',
-            '/api/v3/projects/buildbot%2Fbuildbot', content_json={
+            '/api/v4/projects/buildbot%2Fbuildbot', content_json={
                 "id": 1
             })
         self._http.expect(
             'post',
-            '/api/v3/projects/1/statuses/d34db33fd43db33f',
+            '/api/v4/projects/1/statuses/d34db33fd43db33f',
             json={'state': 'running',
                   'target_url': 'http://localhost:8080/#builders/79/builds/0',
                   'ref': 'master',
                   'description': 'Build started.', 'name': 'buildbot/Builder0'})
         self._http.expect(
             'post',
-            '/api/v3/projects/1/statuses/d34db33fd43db33f',
+            '/api/v4/projects/1/statuses/d34db33fd43db33f',
             json={'state': 'success',
                   'target_url': 'http://localhost:8080/#builders/79/builds/0',
                   'ref': 'master',
                   'description': 'Build done.', 'name': 'buildbot/Builder0'})
         self._http.expect(
             'post',
-            '/api/v3/projects/1/statuses/d34db33fd43db33f',
+            '/api/v4/projects/1/statuses/d34db33fd43db33f',
             json={'state': 'failed',
                   'target_url': 'http://localhost:8080/#builders/79/builds/0',
                   'ref': 'master',
@@ -107,12 +107,12 @@ def test_sshurl(self):
         # we make sure proper calls to txrequests have been made
         self._http.expect(
             'get',
-            '/api/v3/projects/buildbot%2Fbuildbot', content_json={
+            '/api/v4/projects/buildbot%2Fbuildbot', content_json={
                 "id": 1
             })
         self._http.expect(
             'post',
-            '/api/v3/projects/1/statuses/d34db33fd43db33f',
+            '/api/v4/projects/1/statuses/d34db33fd43db33f',
             json={'state': 'running',
                   'target_url': 'http://localhost:8080/#builders/79/builds/0',
                   'ref': 'master',
@@ -127,7 +127,7 @@ def test_merge_request_forked(self):
         build = yield self.setupBuildResults(SUCCESS)
         self._http.expect(
             'post',
-            '/api/v3/projects/20922342342/statuses/d34db33fd43db33f',
+            '/api/v4/projects/20922342342/statuses/d34db33fd43db33f',
             json={'state': 'running',
                   'target_url': 'http://localhost:8080/#builders/79/builds/0',
                   'ref': 'master',
@@ -145,7 +145,7 @@ def test_noproject(self):
         # we make sure proper calls to txrequests have been made
         self._http.expect(
             'get',
-            '/api/v3/projects/buildbot%2Fbuildbot', content_json={
+            '/api/v4/projects/buildbot%2Fbuildbot', content_json={
                 "message": 'project not found'
             }, code=404)
         build['complete'] = False
@@ -169,12 +169,12 @@ def test_senderror(self):
         # we make sure proper calls to txrequests have been made
         self._http.expect(
             'get',
-            '/api/v3/projects/buildbot%2Fbuildbot', content_json={
+            '/api/v4/projects/buildbot%2Fbuildbot', content_json={
                 "id": 1
             })
         self._http.expect(
             'post',
-            '/api/v3/projects/1/statuses/d34db33fd43db33f',
+            '/api/v4/projects/1/statuses/d34db33fd43db33f',
             json={'state': 'running',
                   'target_url': 'http://localhost:8080/#builders/79/builds/0',
                   'ref': 'master',
@@ -194,7 +194,7 @@ def test_badchange(self):
         # we make sure proper calls to txrequests have been made
         self._http.expect(
             'get',
-            '/api/v3/projects/buildbot%2Fbuildbot', content_json={
+            '/api/v4/projects/buildbot%2Fbuildbot', content_json={
                 "id": 1
             })
         build['complete'] = False