(ctx context.Context, shellCommand string, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader)
| 274 | } |
| 275 | |
| 276 | func executeShellCommand(ctx context.Context, shellCommand string, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader) error { |
| 277 | extraEnv := map[string]string{} |
| 278 | for k, v := range variables { |
| 279 | extraEnv[k] = fmt.Sprintf("%v", v) |
| 280 | } |
| 281 | |
| 282 | // execute the command in a shell |
| 283 | err := engine.ExecuteSimpleShellCommand(ctx, dir, env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), extraEnv), stdout, stderr, stdin, shellCommand, args...) |
| 284 | if err != nil { |
| 285 | if status, ok := interp.IsExitStatus(err); ok { |
| 286 | return &exit.ReturnCodeError{ |
| 287 | ExitCode: int(status), |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | return errors.Wrap(err, "execute command") |
| 292 | } |
| 293 | |
| 294 | return nil |
| 295 | } |
| 296 | |
| 297 | // ExecuteCommand executes a command from the config |
| 298 | func ExecuteCommand(ctx context.Context, cmd *latest.CommandConfig, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader) error { |
no test coverage detected