diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 8bd8f65afb4..37e27f6050b 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -751,24 +751,23 @@ func usesWindows(tr *v1.TaskRun) bool { } func artifactsPathReferenced(steps []v1.Step) bool { - unresolvedPath := "$(step.artifacts.path)" for i, step := range steps { path := filepath.Join(pipeline.StepsDir, StepName(step.Name, i), "artifacts", "provenance.json") - if strings.Contains(step.Script, path) || strings.Contains(step.Script, unresolvedPath) { + if strings.Contains(step.Script, path) { return true } for _, arg := range step.Args { - if strings.Contains(arg, path) || strings.Contains(arg, unresolvedPath) { + if strings.Contains(arg, path) { return true } } for _, c := range step.Command { - if strings.Contains(c, path) || strings.Contains(c, unresolvedPath) { + if strings.Contains(c, path) { return true } } for _, e := range step.Env { - if strings.Contains(e.Value, path) || strings.Contains(e.Value, unresolvedPath) { + if strings.Contains(e.Value, path) { return true } } diff --git a/pkg/pod/pod_test.go b/pkg/pod/pod_test.go index 836b853cf7b..c17bb158a07 100644 --- a/pkg/pod/pod_test.go +++ b/pkg/pod/pod_test.go @@ -3942,52 +3942,6 @@ func Test_artifactsPathReferenced(t *testing.T) { }, want: true, }, - { - name: "Unresolved reference in Script", - steps: []v1.Step{ - { - Name: "name", - Script: "echo aaa >> $(step.artifacts.path)", - }, - }, - want: true, - }, - { - name: "Unresolved reference in Args", - steps: []v1.Step{ - { - Name: "name", - Command: []string{"cat"}, - Args: []string{"$(step.artifacts.path)"}, - }, - }, - want: true, - }, - { - name: "Unresolved reference in Command", - steps: []v1.Step{ - { - Name: "name", - Command: []string{"cat", "$(step.artifacts.path)"}, - }, - }, - want: true, - }, - { - name: "Unresolved reference in Env", - steps: []v1.Step{ - { - Name: "name", - Env: []corev1.EnvVar{ - { - Name: "MY_VAR", - Value: "$(step.artifacts.path)", - }, - }, - }, - }, - want: true, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/pod/status.go b/pkg/pod/status.go index ec659d49b03..b83e40d29dd 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -223,9 +223,11 @@ func setTaskRunStatusBasedOnStepStatus(ctx context.Context, logger *zap.SugaredL // Extract results from sidecar logs sidecarLogsResultsEnabled := config.FromContextOrDefaults(ctx).FeatureFlags.ResultExtractionMethod == config.ResultExtractionMethodSidecarLogs // temporary solution to check if artifacts sidecar created in taskRun as we don't have the api for users to declare if a step/task is producing artifacts yet - artifactsSidecarCreated := artifactsPathReferenced(ts.Steps) + artifactsSidecarCreated := false + if tr.Spec.TaskSpec != nil { + artifactsSidecarCreated = artifactsPathReferenced(tr.Spec.TaskSpec.Steps) + } sidecarLogResults := []result.RunResult{} - sidecarArtifacts := map[string]v1.Artifacts{} if sidecarLogsResultsEnabled { diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index 44ac4df717c..6042d301677 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -174,6 +174,7 @@ func TestSetTaskRunStatusBasedOnStepStatus_sidecar_logs(t *testing.T) { PodName: "task-run-pod", }, }, + Spec: v1.TaskRunSpec{TaskSpec: &v1.TaskSpec{Steps: []v1.Step{{Name: "name", Script: `echo aaa >> /tekton/steps/step-name/artifacts/provenance.json`}}}}, }, maxResultSize: 1, wantErr: sidecarlogresults.ErrSizeExceeded, @@ -191,6 +192,7 @@ func TestSetTaskRunStatusBasedOnStepStatus_sidecar_logs(t *testing.T) { PodName: "task-run-pod", }, }, + Spec: v1.TaskRunSpec{TaskSpec: &v1.TaskSpec{Steps: []v1.Step{{Name: "name", Script: `echo aaa >> /tekton/steps/step-name/artifacts/provenance.json`}}}}, }, maxResultSize: 4096, wantErr: fmt.Errorf("%s", "invalid result \"\": invalid character 'k' in literal false (expecting 'l')"), @@ -231,7 +233,6 @@ func TestSetTaskRunStatusBasedOnStepStatus_sidecar_logs(t *testing.T) { ts := &v1.TaskSpec{} if c.enableArtifacts { featureFlags.EnableArtifacts = true - ts.Steps = []v1.Step{{Name: "name", Script: `echo aaa >> /tekton/steps/step-name/artifacts/provenance.json`}} } ctx := config.ToContext(context.Background(), &config.Config{ FeatureFlags: featureFlags,