Skip to content

Commit

Permalink
feat: [PIPE-25062]: Unify output variables logic for V0 and V1 pipeli…
Browse files Browse the repository at this point in the history
…nes (#337)

* use outputFile's value for HARNESS_OUTPUT_FILE env
* Fix comment
* Unify output variables logic for V0 and V1 pipelines
  • Loading branch information
vcalasansh authored and Harness committed Feb 26, 2025
1 parent 6c5aa34 commit 2ca0ace
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pipeline/runtime/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2ca0ace

Please sign in to comment.