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 2024/09/20 03:25:15 UTC

(incubator-devlake) branch zk-0920 updated: fix: jenkins can not get scope config

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

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


The following commit(s) were added to refs/heads/zk-0920 by this push:
     new b0a04b860 fix: jenkins can not get scope config
b0a04b860 is described below

commit b0a04b860b1b1dfb286ffc19d9c4c18cf38252f6
Author: abeizn <zi...@merico.dev>
AuthorDate: Fri Sep 20 11:25:06 2024 +0800

    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..cc96b6a27 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.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 == "" && *op.ScopeConfig.ProductionPattern == "" && op.ScopeConfigId == 0 {
+		op.ScopeConfig = new(models.JenkinsScopeConfig)
 	}
+
 	return nil
 }