Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
moskyb committed Feb 26, 2023
1 parent 49d5d3f commit e0cd7ca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Available commands are:
meta-data Get/set data from Buildkite jobs
pipeline Make changes to the pipeline of the currently running build
step Make changes to a step (this includes any jobs that were created from the step)
bootstrap Run a Buildkite job locally
bootstrap [DEPRECATED] Run a Buildkite job locally
exec-job Run a Buildkite job locally
help Shows a list of commands or help for one command
Use "buildkite-agent <command> --help" for more information about a command.
Expand Down
4 changes: 2 additions & 2 deletions clicommand/agent_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ var AgentStartCommand = cli.Command{
cli.StringFlag{
Name: "bootstrap-script",
Value: "",
Usage: "The command that is executed for bootstrapping a job, defaults to the exec-job sub-command of this binary",
Usage: "[DEPRECATED] The command that is executed for bootstrapping a job, defaults to the exec-job sub-command of this binary",
EnvVar: "BUILDKITE_BOOTSTRAP_SCRIPT_PATH",
},
cli.StringFlag{
Expand Down Expand Up @@ -656,7 +656,7 @@ var AgentStartCommand = cli.Command{
cfg.NoPTY = true
}

// Set a useful default for the bootstrap script
// Set a useful default for the job exec script
if cfg.JobExecutorScript == "" {
exePath, err := os.Executable()
if err != nil {
Expand Down
35 changes: 21 additions & 14 deletions clicommand/exec-job.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ type ExecJobConfig struct {
Debug bool `cli:"debug"`
Shell string `cli:"shell"`
Experiments []string `cli:"experiment" normalize:"list"`
Phases []string `cli:"phases" normalize:"list"`
Phases []string `cli:"phases" normalize:"list" deprecated-and-renamed-to:"exec-phases"`
ExecPhases []string `cli:"exec-phases" normalize:"list"`
Profile string `cli:"profile"`
CancelSignal string `cli:"cancel-signal"`
RedactedVars []string `cli:"redacted-vars" normalize:"list"`
Expand Down Expand Up @@ -322,6 +323,11 @@ var execJobFlags = []cli.Flag{
},
cli.StringSliceFlag{
Name: "phases",
Usage: "[DEPRECATED] The specific phases to execute. The order they're defined is irrelevant.",
EnvVar: "BUILDKITE_BOOTSTRAP_PHASES",
},
cli.StringSliceFlag{
Name: "exec-phases",
Usage: "The specific phases to execute. The order they're defined is irrelevant.",
EnvVar: "BUILDKITE_BOOTSTRAP_PHASES",
},
Expand Down Expand Up @@ -509,16 +515,12 @@ func execJobAction(c *cli.Context) {
os.Exit(exitCode)
}

var (
BootstrapCommand = genBootstrap()
ExecJobCommand = genExecJob()
)

func genBootstrap() cli.Command {
var help strings.Builder
help.WriteString("⚠️ ⚠️ ⚠️\n")
help.WriteString("DEPRECATED: Use `buildkite-agent exec-job` instead\n")
help.WriteString("⚠️ ⚠️ ⚠️\n\n")

err := execJobHelpTpl.Execute(&help, "bootstrap")
if err != nil {
// This can only hapen if we've mangled the template or its parsing
Expand All @@ -532,7 +534,13 @@ func genBootstrap() cli.Command {
Usage: "[DEPRECATED] Run a Buildkite job locally",
Description: help.String(),
Flags: execJobFlags,
Action: execJobAction,
Action: func(c *cli.Context) {
fmt.Println("⚠️ WARNING ⚠️")
fmt.Println("This command (`buildkite-agent bootstrap`) is deprecated and will be removed in a future release")
fmt.Println("Please use `buildkite-agent exec-job` instead")
fmt.Println("")
execJobAction(c)
},
}
}

Expand All @@ -551,12 +559,11 @@ func genExecJob() cli.Command {
Usage: "Run a Buildkite job locally",
Description: help.String(),
Flags: execJobFlags,
Action: func(c *cli.Context) {
fmt.Println("⚠️ WARNING ⚠️")
fmt.Println("This command (`buildkite-agent bootstrap`) is deprecated and will be removed in a future release")
fmt.Println("Please use `buildkite-agent exec-job` instead.")
fmt.Println("")
execJobAction(c)
},
Action: execJobAction,
}
}

var (
BootstrapCommand = genBootstrap()
ExecJobCommand = genExecJob()
)
2 changes: 1 addition & 1 deletion job/integration/executor_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (b *ExecutorTester) Run(t *testing.T, env ...string) error {

buf := &buffer{}

if os.Getenv("DEBUG_BOOTSTRAP") == "1" {
if os.Getenv("DEBUG_JOB_EXEC") == "1" {
w := newTestLogWriter(t)
b.cmd.Stdout = io.MultiWriter(buf, w)
b.cmd.Stderr = io.MultiWriter(buf, w)
Expand Down

0 comments on commit e0cd7ca

Please sign in to comment.