-
Notifications
You must be signed in to change notification settings - Fork 247
/
rerun.go
50 lines (38 loc) · 1013 Bytes
/
rerun.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package commands
import (
"errors"
"github.com/spf13/cobra"
)
const rerunUsage = `Request that Brigade re-run a build.
This will clone an old event, assign it a new build ID, and resubmit it. The build
must still be accessible. Once a build is vacuumed, it can no longer be re-run.
`
var rerunLogLevel string
func init() {
rerun.Flags().StringVarP(&rerunLogLevel, "level", "l", "log", "Specified log level: log, info, warn, error")
Root.AddCommand(rerun)
}
var rerun = &cobra.Command{
Use: "rerun BUILD_ID",
Short: "Given an existing build ID, re-run the same event.",
Long: rerunUsage,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("build ID required")
}
bid := args[0]
a, err := newScriptRunner()
if err != nil {
return err
}
build, err := a.getBuild(bid)
if err != nil {
return err
}
// Override a few things
build.ID = ""
build.LogLevel = rerunLogLevel
build.Worker = nil
return a.sendBuild(build)
},
}