diff --git a/pkg/jobparser/model.go b/pkg/jobparser/model.go index 3236704..d68545b 100644 --- a/pkg/jobparser/model.go +++ b/pkg/jobparser/model.go @@ -168,6 +168,7 @@ type ContainerSpec struct { Volumes []string `yaml:"volumes,omitempty"` Options string `yaml:"options,omitempty"` Credentials map[string]string `yaml:"credentials,omitempty"` + Cmd []string `yaml:"cmd,omitempty"` } type Strategy struct { diff --git a/pkg/model/workflow.go b/pkg/model/workflow.go index a77a688..d39c405 100644 --- a/pkg/model/workflow.go +++ b/pkg/model/workflow.go @@ -522,6 +522,9 @@ type ContainerSpec struct { Args string Name string Reuse bool + + // Gitea specific + Cmd []string `yaml:"cmd"` } // Step is the structure of one step in a job diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index e7f9e2b..64d4f20 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -246,6 +246,7 @@ func (rc *RunContext) startJobContainer() common.Executor { // add service containers for name, spec := range rc.Run.Job().Services { + // interpolate env interpolatedEnvs := make(map[string]string, len(spec.Env)) for k, v := range spec.Env { interpolatedEnvs[k] = rc.ExprEval.Interpolate(ctx, v) @@ -254,6 +255,11 @@ func (rc *RunContext) startJobContainer() common.Executor { for k, v := range interpolatedEnvs { envs = append(envs, fmt.Sprintf("%s=%s", k, v)) } + // interpolate cmd + interpolatedCmd := make([]string, 0, len(spec.Cmd)) + for _, v := range spec.Cmd { + interpolatedCmd = append(interpolatedCmd, rc.ExprEval.Interpolate(ctx, v)) + } serviceContainerName := createSimpleContainerName(rc.jobContainerName(), name) c := container.NewContainer(&container.NewContainerInput{ Name: serviceContainerName, @@ -261,6 +267,7 @@ func (rc *RunContext) startJobContainer() common.Executor { Image: spec.Image, Username: username, Password: password, + Cmd: interpolatedCmd, Env: envs, Mounts: map[string]string{ // TODO merge volumes