This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new b020c26b fix: ignore collect pipeline 403 for CI/CD disable (#2397)
b020c26b is described below

commit b020c26beb8f501fe14544e86c91e52e987c79fb
Author: mappjzc <[email protected]>
AuthorDate: Thu Jun 30 22:07:07 2022 +0800

    fix: ignore collect pipeline 403 for CI/CD disable (#2397)
    
    Add ignoreHTTPStatus403 to ignore the http code 403
    For collect pipeline with CI/CD disable.
    
    Nddtfjiang <[email protected]>
---
 plugins/gitlab/tasks/api_client.go         | 10 +++++++++-
 plugins/gitlab/tasks/pipeline_collector.go |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/plugins/gitlab/tasks/api_client.go 
b/plugins/gitlab/tasks/api_client.go
index 80e0b1e1..c15500aa 100644
--- a/plugins/gitlab/tasks/api_client.go
+++ b/plugins/gitlab/tasks/api_client.go
@@ -19,11 +19,12 @@ package tasks
 
 import (
        "fmt"
-       "github.com/apache/incubator-devlake/plugins/gitlab/models"
        "net/http"
        "strconv"
        "time"
 
+       "github.com/apache/incubator-devlake/plugins/gitlab/models"
+
        "github.com/apache/incubator-devlake/plugins/core"
        "github.com/apache/incubator-devlake/plugins/helper"
 )
@@ -72,3 +73,10 @@ func NewGitlabApiClient(taskCtx core.TaskContext, connection 
*models.GitlabConne
        }
        return asyncApiClient, nil
 }
+
+func ignoreHTTPStatus403(res *http.Response) error {
+       if res.StatusCode == http.StatusForbidden {
+               return helper.ErrIgnoreAndContinue
+       }
+       return nil
+}
diff --git a/plugins/gitlab/tasks/pipeline_collector.go 
b/plugins/gitlab/tasks/pipeline_collector.go
index 5fc88b59..63f72f2b 100644
--- a/plugins/gitlab/tasks/pipeline_collector.go
+++ b/plugins/gitlab/tasks/pipeline_collector.go
@@ -43,6 +43,7 @@ func CollectApiPipelines(taskCtx core.SubTaskContext) error {
                UrlTemplate:        "projects/{{ .Params.ProjectId 
}}/pipelines",
                Query:              GetQuery,
                ResponseParser:     GetRawMessageFromResponse,
+               AfterResponse:      ignoreHTTPStatus403, // ignore 403 for 
CI/CD disable
        })
 
        if err != nil {

Reply via email to