diff --git a/pkg/apis/pipeline/v1beta1/resultref.go b/pkg/apis/pipeline/v1beta1/resultref.go index b4f16998a28..478cb62c479 100644 --- a/pkg/apis/pipeline/v1beta1/resultref.go +++ b/pkg/apis/pipeline/v1beta1/resultref.go @@ -33,8 +33,9 @@ const ( // ResultTaskPart Constant used to define the "tasks" part of a pipeline result reference ResultTaskPart = "tasks" // ResultResultPart Constant used to define the "results" part of a pipeline result reference - ResultResultPart = "results" - variableSubstitutionFormat = `\$\([A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\)` + ResultResultPart = "results" + // TODO(#2462) use one regex across all substitutions + variableSubstitutionFormat = `\$\([_a-zA-Z0-9.-]+(\.[_a-zA-Z0-9.-]+)*\)` ) var variableSubstitutionRegex = regexp.MustCompile(variableSubstitutionFormat) @@ -56,7 +57,7 @@ func NewResultRefs(expressions []string) ([]*ResultRef, error) { return resultRefs, nil } -// looksLikeContainsResultRefs attempts to check if param or a pipeline result looks like it contains any +// LooksLikeContainsResultRefs attempts to check if param or a pipeline result looks like it contains any // result references. // This is useful if we want to make sure the param looks like a ResultReference before // performing strict validation diff --git a/pkg/apis/pipeline/v1beta1/resultref_test.go b/pkg/apis/pipeline/v1beta1/resultref_test.go index d2b55a1ad23..de488ff75e3 100644 --- a/pkg/apis/pipeline/v1beta1/resultref_test.go +++ b/pkg/apis/pipeline/v1beta1/resultref_test.go @@ -206,6 +206,23 @@ func TestHasResultReference(t *testing.T) { Result: "sum-result", }, }, + }, { + name: "Test valid expression with underscores", + args: args{ + param: v1beta1.Param{ + Name: "param", + Value: v1beta1.ArrayOrString{ + Type: v1beta1.ParamTypeString, + StringVal: "$(tasks.sum-task.results.sum_result)", + }, + }, + }, + wantRef: []*v1beta1.ResultRef{ + { + PipelineTask: "sum-task", + Result: "sum_result", + }, + }, }, { name: "Test invalid expression: param substitution shouldn't be considered result ref", args: args{