Skip to content

Commit

Permalink
Error if pipeline doesn't exist (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcncl authored Nov 24, 2024
1 parent af15027 commit e841ded
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/cmd/build/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func NewCmdBuildNew(f *factory.Factory) *cobra.Command {
}

func newBuild(ctx context.Context, org string, pipeline string, f *factory.Factory, message string, commit string, branch string, web bool, env map[string]string, ignoreBranchFilters bool) error {
var err error
var actionErr error
var build buildkite.Build
spinErr := spinner.New().
Title(fmt.Sprintf("Starting new build for %s", pipeline)).
Expand All @@ -118,6 +118,7 @@ func newBuild(ctx context.Context, org string, pipeline string, f *factory.Facto
if len(branch) == 0 {
p, _, err := f.RestAPIClient.Pipelines.Get(ctx, org, pipeline)
if err != nil {
actionErr = fmt.Errorf("Error getting pipeline: %w", err)
return
}
branch = p.DefaultBranch
Expand All @@ -131,14 +132,20 @@ func newBuild(ctx context.Context, org string, pipeline string, f *factory.Facto
IgnorePipelineBranchFilters: ignoreBranchFilters,
}

var err error
build, _, err = f.RestAPIClient.Builds.Create(ctx, org, pipeline, newBuild)
if err != nil {
actionErr = fmt.Errorf("Error creating build: %w", err)
return
}
}).
Run()
if spinErr != nil {
return spinErr
}
if err != nil {
return err

if actionErr != nil {
return actionErr
}

if build.WebURL == "" {
Expand Down

0 comments on commit e841ded

Please sign in to comment.