From 778bd4813affd226d50cbaaffa426d8ebbf77881 Mon Sep 17 00:00:00 2001 From: Bruno Meneguele Date: Wed, 11 Aug 2021 17:36:31 -0300 Subject: [PATCH] gitlab: remove project ID lookup for CI Bridge jobs The project ID for Bridge jobs (downstream pipeline) were being retrieved from the WebURL text butchering plus one additional API request for looking up the project based on the name. Few releases ago GitLab started to expose the project ID in the pipeline object for such jobs. Now, it's possible to get it without any additional pipeline request. Signed-off-by: Bruno Meneguele --- internal/gitlab/gitlab.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/internal/gitlab/gitlab.go b/internal/gitlab/gitlab.go index 4a966d21..3c41e933 100644 --- a/internal/gitlab/gitlab.go +++ b/internal/gitlab/gitlab.go @@ -1273,25 +1273,8 @@ func CIJobs(pid interface{}, id int, followBridge bool, bridgeName string) ([]Jo continue } - // Unfortunately the GitLab API doesn't exposes the project ID nor name that the - // bridge job points to, since it might be extarnal to the config core.host - // hostname, hence the WebURL is exposed. - // With that, and considering we don't want to support anything outside the - // core.host, we need to massage the WebURL to get the project name that we can - // search for. - // WebURL format: - // //-/pipelines/ - projectName := strings.Replace(bridge.DownstreamPipeline.WebURL, host+"/", "", 1) - pipelineText := fmt.Sprintf("/-/pipelines/%d", bridge.DownstreamPipeline.ID) - projectName = strings.Replace(projectName, pipelineText, "", 1) - - p, err := FindProject(projectName) - if err != nil { - continue - } - // Switch to the new project name and downstream pipeline id - pid = p.PathWithNamespace + pid = bridge.DownstreamPipeline.ProjectID id = bridge.DownstreamPipeline.ID for {