Skip to content

Commit

Permalink
feat: add an option to skip builds for draft PR
Browse files Browse the repository at this point in the history
Signed-off-by: ankitm123 <[email protected]>
  • Loading branch information
ankitm123 committed Sep 26, 2022
1 parent 7f70285 commit 14d301c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/config/job/presubmit.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Presubmit struct {
// (Default: `/test <job name>`)
RerunCommand string `json:"rerun_command,omitempty"`
JenkinsSpec *JenkinsSpec `json:"jenkins_spec,omitempty"`
// SkipDraftPRBuild controls if we want to build a PR in draft mode
SkipDraftPRBuild bool `default:"false" json:"skip_draft_pr_build,omitempty"`

// We'll set these when we load it.
// re *regexp.Regexp // from Trigger.
Expand Down Expand Up @@ -115,6 +117,10 @@ func (p Presubmit) ShouldRun(baseRef string, changes ChangedFilesProvider, force
return false, err
} else if determined {
return shouldRun, nil

// Skip pre-submit job if skip draft PR build flag is set to true
if p.SkipDraftPRBuild {
return false, nil
}

// TODO temporary disable RequireRun
Expand Down
2 changes: 1 addition & 1 deletion pkg/triggerconfig/inrepo/default_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func DefaultPipelineParameters(prs *v1beta1.PipelineRun) (*v1beta1.PipelineRun,

// lets avoid missing workspaces causing issues
if len(prs.Spec.Workspaces) > 0 {
for i, _ := range prs.Spec.Workspaces {
for i := range prs.Spec.Workspaces {
w := &prs.Spec.Workspaces[i]
if w.Validate(ctx) != nil {
// lets default a workspace
Expand Down

0 comments on commit 14d301c

Please sign in to comment.