diff --git a/backend/helpers/pluginhelper/api/enrich_with_regex.go b/backend/helpers/pluginhelper/api/enrich_with_regex.go index d586b81872e..4425fe32188 100644 --- a/backend/helpers/pluginhelper/api/enrich_with_regex.go +++ b/backend/helpers/pluginhelper/api/enrich_with_regex.go @@ -112,7 +112,6 @@ func (r *RegexEnricher) TryAddList(name string, patterns ...string) errors.Error if _, ok := r.regexMapList[name]; ok { return errors.Default.New(fmt.Sprintf("Regex pattern with name: %s already exists", name)) } - var regexList []*regexp.Regexp for _, pattern := range patterns { if pattern == "" { @@ -138,19 +137,14 @@ func (r *RegexEnricher) ReturnNameIfMatchedList(name string, targets ...string) return "" } else { for _, regex := range regexList { - matched := false for _, target := range targets { if regex.MatchString(target) { - matched = true - break + return name } } - if !matched { - return "" // If any regex fails to match, return "" - } } + return "" // If any regex fails to match, return "" } - return name // Return name if all regex conditions were fulfilled } // ReturnNameIfOmittedOrMatched returns the given name if regex of the given name is omitted or fallback to ReturnNameIfMatched diff --git a/backend/plugins/github_graphql/impl/impl.go b/backend/plugins/github_graphql/impl/impl.go index 5b82c753c73..3de0cf34546 100644 --- a/backend/plugins/github_graphql/impl/impl.go +++ b/backend/plugins/github_graphql/impl/impl.go @@ -263,8 +263,14 @@ func (p GithubGraphql) PrepareTaskData(taskCtx plugin.TaskContext, options map[s return nil, errors.BadInput.Wrap(err, "invalid value for `productionPattern`") } } - if err = regexEnricher.TryAdd(devops.ENV_NAME_PATTERN, op.ScopeConfig.EnvNamePattern); err != nil { - return nil, errors.BadInput.Wrap(err, "invalid value for `envNamePattern`") + if len(op.ScopeConfig.EnvNameList) > 0 || (len(op.ScopeConfig.EnvNameList) == 0 && op.ScopeConfig.EnvNamePattern == "") { + if err = regexEnricher.TryAddList(devops.ENV_NAME_PATTERN, op.ScopeConfig.EnvNameList...); err != nil { + return nil, errors.BadInput.Wrap(err, "invalid value for `envNameList`") + } + } else { + if err = regexEnricher.TryAdd(devops.ENV_NAME_PATTERN, op.ScopeConfig.EnvNamePattern); err != nil { + return nil, errors.BadInput.Wrap(err, "invalid value for `envNamePattern`") + } } taskData.RegexEnricher = regexEnricher diff --git a/backend/plugins/github_graphql/tasks/deployment_convertor.go b/backend/plugins/github_graphql/tasks/deployment_convertor.go index c0b6a29aac3..6d292de5640 100644 --- a/backend/plugins/github_graphql/tasks/deployment_convertor.go +++ b/backend/plugins/github_graphql/tasks/deployment_convertor.go @@ -108,7 +108,6 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error { deploymentCommit.Environment = devops.PRODUCTION } } - deploymentCommit.CicdDeploymentId = deploymentCommit.Id return []interface{}{ deploymentCommit,