You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/09/27 11:25:13 UTC
[incubator-devlake] branch main updated: fix: Jenkins collectApiStages occurs 404 and Missing parameters transformationRules
This is an automated email from the ASF dual-hosted git repository.
warren 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 524ea066 fix: Jenkins collectApiStages occurs 404 and Missing parameters transformationRules
524ea066 is described below
commit 524ea066e357bd8dc04f924247700f920a548178
Author: abeizn <zi...@merico.dev>
AuthorDate: Tue Sep 27 18:34:43 2022 +0800
fix: Jenkins collectApiStages occurs 404 and Missing parameters transformationRules
fix: Jenkins collectApiStages occurs 404 and Missing parameters transformationRules
---
plugins/jenkins/api/blueprint.go | 2 ++
plugins/jenkins/tasks/shared.go | 35 ++++++++++++++++++++++++++++++++
plugins/jenkins/tasks/stage_collector.go | 4 +++-
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/plugins/jenkins/api/blueprint.go b/plugins/jenkins/api/blueprint.go
index 37fae67c..66105cad 100644
--- a/plugins/jenkins/api/blueprint.go
+++ b/plugins/jenkins/api/blueprint.go
@@ -19,6 +19,7 @@ package api
import (
"encoding/json"
+
"github.com/apache/incubator-devlake/errors"
"github.com/apache/incubator-devlake/plugins/core"
"github.com/apache/incubator-devlake/plugins/helper"
@@ -43,6 +44,7 @@ func MakePipelinePlan(subtaskMetas []core.SubTaskMeta, connectionId uint64, scop
return nil, err
}
taskOptions["connectionId"] = connectionId
+ taskOptions["transformationRules"] = transformationRules
_, err := tasks.DecodeAndValidateTaskOptions(taskOptions)
if err != nil {
return nil, err
diff --git a/plugins/jenkins/tasks/shared.go b/plugins/jenkins/tasks/shared.go
new file mode 100644
index 00000000..f2249349
--- /dev/null
+++ b/plugins/jenkins/tasks/shared.go
@@ -0,0 +1,35 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+ "net/http"
+
+ "github.com/apache/incubator-devlake/errors"
+ "github.com/apache/incubator-devlake/plugins/helper"
+)
+
+func ignoreHTTPStatus404(res *http.Response) errors.Error {
+ if res.StatusCode == http.StatusUnauthorized {
+ return errors.Unauthorized.New("authentication failed, please check your AccessToken")
+ }
+ if res.StatusCode == http.StatusNotFound {
+ return helper.ErrIgnoreAndContinue
+ }
+ return nil
+}
diff --git a/plugins/jenkins/tasks/stage_collector.go b/plugins/jenkins/tasks/stage_collector.go
index 9cd249c5..8411ac01 100644
--- a/plugins/jenkins/tasks/stage_collector.go
+++ b/plugins/jenkins/tasks/stage_collector.go
@@ -19,11 +19,12 @@ package tasks
import (
"encoding/json"
- "github.com/apache/incubator-devlake/errors"
"net/http"
"net/url"
"reflect"
+ "github.com/apache/incubator-devlake/errors"
+
"github.com/apache/incubator-devlake/plugins/core"
"github.com/apache/incubator-devlake/plugins/core/dal"
"github.com/apache/incubator-devlake/plugins/helper"
@@ -96,6 +97,7 @@ func CollectApiStages(taskCtx core.SubTaskContext) errors.Error {
}
return data.Stages, nil
},
+ AfterResponse: ignoreHTTPStatus404,
})
if err != nil {