You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2022/09/20 13:08:37 UTC

[incubator-devlake] branch main updated: feat(jenkins): add dora enrich

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

abeizn 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 15d8f7d2 feat(jenkins): add dora enrich
15d8f7d2 is described below

commit 15d8f7d2c08560f4ac854374ec91eef76050aec6
Author: Yingchu Chen <yi...@merico.dev>
AuthorDate: Tue Sep 20 20:43:21 2022 +0800

    feat(jenkins): add dora enrich
---
 plugins/jenkins/api/blueprint.go | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/plugins/jenkins/api/blueprint.go b/plugins/jenkins/api/blueprint.go
index 62eea658..a4f1e426 100644
--- a/plugins/jenkins/api/blueprint.go
+++ b/plugins/jenkins/api/blueprint.go
@@ -30,6 +30,13 @@ func MakePipelinePlan(subtaskMetas []core.SubTaskMeta, connectionId uint64, scop
 	plan := make(core.PipelinePlan, len(scope))
 	for i, scopeElem := range scope {
 		// handle taskOptions and transformationRules, by dumping them to taskOptions
+		transformationRules := make(map[string]interface{})
+		if len(scopeElem.Transformation) > 0 {
+			err = errors.Convert(json.Unmarshal(scopeElem.Transformation, &transformationRules))
+			if err != nil {
+				return nil, err
+			}
+		}
 		taskOptions := make(map[string]interface{})
 		err = errors.Convert(json.Unmarshal(scopeElem.Options, &taskOptions))
 		if err != nil {
@@ -52,7 +59,30 @@ func MakePipelinePlan(subtaskMetas []core.SubTaskMeta, connectionId uint64, scop
 				Options:  taskOptions,
 			},
 		}
-
+		if doraRules, ok := transformationRules["dora"]; ok && doraRules != nil {
+			j := i + 1
+			// add a new task to next stage
+			if plan[j] != nil {
+				j++
+			}
+			if j == len(plan) {
+				plan = append(plan, nil)
+			}
+			if err != nil {
+				return nil, err
+			}
+			doraOption := make(map[string]interface{})
+			doraOption["tasks"] = []string{"EnrichTaskEnv"}
+			doraOption["transformation"] = doraRules
+			plan[j] = core.PipelineStage{
+				{
+					Plugin:  "dora",
+					Options: doraOption,
+				},
+			}
+			// remove it from github transformationRules
+			delete(transformationRules, "dora")
+		}
 		plan[i] = stage
 	}
 	return plan, nil