Skip to content

Commit

Permalink
Allow branch filters to be ignored (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcncl authored Oct 10, 2024
1 parent 0585748 commit 80141e2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/cmd/build/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func NewCmdBuildNew(f *factory.Factory) *cobra.Command {
var pipeline string
var confirmed bool
var web bool
var ignoreBranchFilters bool
var env []string
envMap := make(map[string]string)
var envFile string
Expand Down Expand Up @@ -83,7 +84,7 @@ func NewCmdBuildNew(f *factory.Factory) *cobra.Command {
}
}
}
return newBuild(pipeline.Org, pipeline.Name, f, message, commit, branch, web, envMap)
return newBuild(pipeline.Org, pipeline.Name, f, message, commit, branch, web, envMap, ignoreBranchFilters)
} else {
return nil
}
Expand All @@ -98,13 +99,14 @@ func NewCmdBuildNew(f *factory.Factory) *cobra.Command {
"If omitted, it will be resolved using the current directory.",
)
cmd.Flags().StringArrayVarP(&env, "env", "e", []string{}, "Set environment variables for the build")
cmd.Flags().BoolVarP(&ignoreBranchFilters, "ignore-branch-filters", "i", false, "Ignore branch filters for the pipeline")
cmd.Flags().BoolVarP(&confirmed, "yes", "y", false, "Skip the confirmation prompt. Useful if being used in automation/CI")
cmd.Flags().StringVarP(&envFile, "envFile", "f", "", "Set the environment variables for the build via an environment file")
cmd.Flags().BoolVarP(&confirmed, "yes", "y", false, "Skip the confirmation prompt. Useful if being used in automation/CI.")
cmd.Flags().SortFlags = false
return &cmd
}

func newBuild(org string, pipeline string, f *factory.Factory, message string, commit string, branch string, web bool, env map[string]string) error {
func newBuild(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 build *buildkite.Build
spinErr := spinner.New().
Expand All @@ -120,10 +122,11 @@ func newBuild(org string, pipeline string, f *factory.Factory, message string, c
}

newBuild := buildkite.CreateBuild{
Message: message,
Commit: commit,
Branch: branch,
Env: env,
Message: message,
Commit: commit,
Branch: branch,
Env: env,
IgnorePipelineBranchFilters: ignoreBranchFilters,
}

build, _, err = f.RestAPIClient.Builds.Create(org, pipeline, &newBuild)
Expand Down

0 comments on commit 80141e2

Please sign in to comment.