diff --git a/pipeline/runtime/run.go b/pipeline/runtime/run.go index 578a39ea..ff79bb0e 100644 --- a/pipeline/runtime/run.go +++ b/pipeline/runtime/run.go @@ -49,24 +49,24 @@ func executeRunStep(ctx context.Context, f RunFunc, r *api.StartStepRequest, out step.Envs["HARNESS_SCRATCH_DIR"] = r.ScratchDir } - // If the output variable file is set, it means we use the file directly to get the output variables - // instead of explicitly modifying the input command. var outputFile string if r.OutputVarFile != "" { - // Plugins can use HARNESS_OUTPUT_FILE to write the output variables to a file. - step.Envs["HARNESS_OUTPUT_FILE"] = r.OutputVarFile + // If the output variable file is set, we use it to write the output variables outputFile = r.OutputVarFile } else { - // If output variable file is not set, we auto append the run command to write output - // variables. + // Otherwise, we use the default output file path outputFile = fmt.Sprintf("%s/%s-output.env", pipeline.SharedVolPath, step.ID) - step.Envs["DRONE_OUTPUT"] = outputFile + } - if len(r.Outputs) > 0 { - step.Command[0] += getOutputsCmd(step.Entrypoint, r.Outputs, outputFile) - } else if len(r.OutputVars) > 0 { - step.Command[0] += getOutputVarCmd(step.Entrypoint, r.OutputVars, outputFile) - } + // Plugins can use HARNESS_OUTPUT_FILE to write the output variables to a file. + step.Envs["HARNESS_OUTPUT_FILE"] = outputFile + step.Envs["DRONE_OUTPUT"] = outputFile + + // Here we auto append the run command to write output variables. + if len(r.Outputs) > 0 { + step.Command[0] += getOutputsCmd(step.Entrypoint, r.Outputs, outputFile) + } else if len(r.OutputVars) > 0 { + step.Command[0] += getOutputVarCmd(step.Entrypoint, r.OutputVars, outputFile) } var outputSecretsFile string