This is an automated email from the ASF dual-hosted git repository.
mappjzc 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 8902994e2 fix: jenkins multi-dirs can not collect (#4073)
8902994e2 is described below
commit 8902994e2bc873270111232710a94d814acd750f
Author: abeizn <[email protected]>
AuthorDate: Fri Dec 30 14:02:56 2022 +0800
fix: jenkins multi-dirs can not collect (#4073)
* fix: jenkins multi-dirs can not collect
* fix: jenkins multi-dirs can not collect
---
plugins/jenkins/impl/impl.go | 51 +++++++++++++++++++-------------------------
1 file changed, 22 insertions(+), 29 deletions(-)
diff --git a/plugins/jenkins/impl/impl.go b/plugins/jenkins/impl/impl.go
index 7bea90ef7..3f5b283a0 100644
--- a/plugins/jenkins/impl/impl.go
+++ b/plugins/jenkins/impl/impl.go
@@ -224,43 +224,36 @@ func EnrichOptions(taskCtx core.TaskContext,
dal.Where(`connection_id = ? and full_name = ?`,
op.ConnectionId, op.JobFullName))
if err == nil {
- op.Name = jenkinsJob.Name
- op.JobPath = jenkinsJob.Path
if op.TransformationRuleId == 0 {
op.TransformationRuleId =
jenkinsJob.TransformationRuleId
}
- } else {
- if taskCtx.GetDal().IsErrorNotFound(err) && op.JobFullName !=
"" {
-
- pathSplit := strings.Split(op.JobFullName, "/")
- lastOne := len(pathSplit)
-
- path := "job/" + strings.Join(pathSplit[0:lastOne-1],
"job/")
- if path == "job/" {
- path = ""
- }
- name := pathSplit[lastOne-1]
-
- err = api.GetJob(apiClient, path, name, op.JobFullName,
100, func(job *models.Job, isPath bool) errors.Error {
- log.Debug(fmt.Sprintf("Current job: %s",
job.FullName))
- op.Name = job.Name
- op.JobPath = job.Path
- jenkinsJob := ConvertJobToJenkinsJob(job, op)
- err =
taskCtx.GetDal().CreateIfNotExist(jenkinsJob)
- return err
- })
- if err != nil {
- return err
- }
- } else {
- return errors.Default.Wrap(err, fmt.Sprintf("fail to
find repo %s", op.Name))
- }
+ }
+
+ pathSplit := strings.Split(op.JobFullName, "/")
+ lastOne := len(pathSplit)
+
+ // Multi-level directory assembly
+ path := "job/" + strings.Join(pathSplit, "/job/")
+ if path == "job/" {
+ path = ""
+ }
+ name := pathSplit[lastOne-1]
+
+ err = api.GetJob(apiClient, path, name, op.JobFullName, 100, func(job
*models.Job, isPath bool) errors.Error {
+ log.Debug(fmt.Sprintf("Current job: %s", job.FullName))
+ op.Name = job.Name
+ op.JobPath = job.Path
+ jenkinsJob := ConvertJobToJenkinsJob(job, op)
+ err = taskCtx.GetDal().CreateIfNotExist(jenkinsJob)
+ return err
+ })
+ if err != nil {
+ return err
}
if !strings.HasSuffix(op.JobPath, "/") {
op.JobPath = fmt.Sprintf("%s/", op.JobPath)
}
-
// We only set op.JenkinsTransformationRule when it's nil and we have
op.TransformationRuleId != 0
if op.JenkinsTransformationRule == nil && op.TransformationRuleId != 0 {
var transformationRule models.JenkinsTransformationRule