Skip to content

Commit

Permalink
fix: jenkins can not get scope config
Browse files Browse the repository at this point in the history
  • Loading branch information
abeizn committed Sep 20, 2024
1 parent 07aab3b commit b0a04b8
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions backend/plugins/jenkins/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit b0a04b8

Please sign in to comment.