--- a/podman/run.go Mon Oct 11 05:32:52 2021 -0500
+++ b/podman/run.go Mon Oct 11 06:19:45 2021 -0500
@@ -1,6 +1,10 @@
"github.com/kballard/go-shellquote"
"github.com/opencontainers/selinux/go-selinux"
log "github.com/sirupsen/logrus"
@@ -19,6 +23,8 @@
Environment yaml.StringOrSlice `yaml:"environment"`
Hostname string `yaml:"hostname"`
Image string `yaml:"image"`
+ Script yaml.StringOrSlice `yaml:"script"` + Shell string `yaml:"shell"` User string `yaml:"user"`
Workdir string `yaml:"workdir"`
Workspace string `yaml:"workspace"`
@@ -26,6 +32,29 @@
+func (r *Run) buildScript(cfgPath string, env environment.Environment) (string, error) { + script := env.Expandv(r.Script) + fp, err := os.CreateTemp(cfgPath, ".convey-script-") + if _, err = fp.Write([]byte(strings.Join(script, "\n"))); err != nil { + if err := fp.Chmod(0700); err != nil { + if err := fp.Close(); err != nil { func (r *Run) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error {
// Create a new environment based on the stage's environment. Then merge
// the task's environment overriding anything from the stage. Finally merge
@@ -61,6 +90,33 @@
+ // if the user provided a script, generate the file and set all of our + // attributes appropriately. + // Overwrite any entry point that the user provided. Validate set + // /bin/sh if the user didn't provide one. + scriptFile, err := r.buildScript(rt.ConfigPath, env) + defer os.Remove(scriptFile) + scriptFileBase := filepath.Base(scriptFile) + r.commandv = []string{"/" + scriptFileBase} + volume := scriptFile + ":/" + scriptFileBase + if selinux.GetEnabled() { + generator.Append("--volume", volume) // Add any annotations that the user specified.
for _, annotation := range r.Annotations {
generator.Append("--annotation", annotation)
@@ -119,6 +175,10 @@