This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch feat-dora-config in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit e2bb16c6d39bc1d01777f96e976a19ab79d52052 Author: abeizn <zikuan...@merico.dev> AuthorDate: Fri Sep 20 11:34:44 2024 +0800 fix: jenkins can not get scope config (#8080) * fix: jenkins can not get scope config * fix: jenkins can not get scope config --- backend/plugins/jenkins/impl/impl.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/backend/plugins/jenkins/impl/impl.go b/backend/plugins/jenkins/impl/impl.go index be9589152..2a686037f 100644 --- a/backend/plugins/jenkins/impl/impl.go +++ b/backend/plugins/jenkins/impl/impl.go @@ -118,9 +118,6 @@ func (p Jenkins) PrepareTaskData(taskCtx plugin.TaskContext, options map[string] nil, p.Name(), ) - if err != nil { - return nil, err - } err = connectionHelper.FirstById(connection, op.ConnectionId) if err != nil { return nil, err @@ -295,19 +292,18 @@ func EnrichOptions(taskCtx plugin.TaskContext, op.JobPath = fmt.Sprintf("%s/", op.JobPath) } // We only set op.JenkinsScopeConfig when it's nil and we have op.ScopeConfigId != 0 - if op.ScopeConfig.DeploymentPattern != nil && op.ScopeConfig.ProductionPattern != nil { - if *op.ScopeConfig.DeploymentPattern == "" && *op.ScopeConfig.ProductionPattern == "" && op.ScopeConfigId != 0 { - var scopeConfig models.JenkinsScopeConfig - err = taskCtx.GetDal().First(&scopeConfig, dal.Where("id = ?", op.ScopeConfigId)) - if err != nil { - return errors.BadInput.Wrap(err, "fail to get scopeConfig") - } - op.ScopeConfig = &scopeConfig + if (op.ScopeConfig.DeploymentPattern == nil && op.ScopeConfig.ProductionPattern == nil || *op.ScopeConfig.DeploymentPattern == "" && *op.ScopeConfig.ProductionPattern == "") && op.ScopeConfigId != 0 { + var scopeConfig models.JenkinsScopeConfig + err = taskCtx.GetDal().First(&scopeConfig, dal.Where("id = ?", op.ScopeConfigId)) + if err != nil { + return errors.BadInput.Wrap(err, "fail to get scopeConfig") } + op.ScopeConfig = &scopeConfig + } - if *op.ScopeConfig.DeploymentPattern == "" && *op.ScopeConfig.ProductionPattern == "" && op.ScopeConfigId == 0 { - op.ScopeConfig = new(models.JenkinsScopeConfig) - } + if (op.ScopeConfig.DeploymentPattern == nil && op.ScopeConfig.ProductionPattern == nil || *op.ScopeConfig.DeploymentPattern == "" && *op.ScopeConfig.ProductionPattern == "") && op.ScopeConfigId == 0 { + op.ScopeConfig = new(models.JenkinsScopeConfig) } + return nil }