1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

Add needs job output (#629)

* Add outputs field to job model

* Add output interpolation for jobs

* Add otto config reference for interpolated job output values into 'needs' context

* Add output interpolation call after job has completed.

* gofmt

* Remove whitespace

* goimports

Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
Phil Story 2021-07-01 09:20:20 -06:00 committed by GitHub
parent 4229505f5d
commit 5ed5bc15b3
5 changed files with 76 additions and 1 deletions

View file

@ -29,6 +29,7 @@ type StepContext struct {
Env map[string]string
Cmd []string
Action *model.Action
Needs *model.Job
}
func (sc *StepContext) execJobContainer() common.Executor {
@ -37,6 +38,19 @@ func (sc *StepContext) execJobContainer() common.Executor {
}
}
func (sc *StepContext) interpolateOutputs() common.Executor {
return func(ctx context.Context) error {
ee := sc.NewExpressionEvaluator()
for k, v := range sc.RunContext.Run.Job().Outputs {
interpolated := ee.Interpolate(v)
if v != interpolated {
sc.RunContext.Run.Job().Outputs[k] = interpolated
}
}
return nil
}
}
type formatError string
func (e formatError) Error() string {