Skip to content

Commit

Permalink
[PCFF-2900] Add optional stage support (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryguillen authored and mhamrah committed Jun 25, 2019
1 parent b303124 commit 681143a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pipeline/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ func buildStageMetadata(s config.Stage, t string, index int, linear bool) types.
}
}

stageEnabled := types.OptionalStageSupport{
Expression: s.Condition,
Type:"expression",
}

notifications := buildNotifications(s.Notifications)
return types.StageMetadata{
Name: s.Name,
Expand All @@ -698,6 +703,7 @@ func buildStageMetadata(s config.Stage, t string, index int, linear bool) types.
Type: t,
Notifications: notifications,
SendNotifications: (len(notifications) > 0),
StageEnabled: stageEnabled,
}
}

Expand Down
13 changes: 7 additions & 6 deletions pipeline/builder/types/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ type TriggerObject struct {

// StageMetadata is the common components of a stage in spinnaker such as name
type StageMetadata struct {
RefID string `json:"refId,omitempty"`
RequisiteStageRefIds []string `json:"requisiteStageRefIds"`
Name string `json:"name"`
Type string `json:"type"`
Notifications []Notification `json:"notifications,omitempty"`
SendNotifications bool `json:"sendNotifications"`
RefID string `json:"refId,omitempty"`
RequisiteStageRefIds []string `json:"requisiteStageRefIds"`
Name string `json:"name"`
Type string `json:"type"`
Notifications []Notification `json:"notifications,omitempty"`
SendNotifications bool `json:"sendNotifications"`
StageEnabled OptionalStageSupport `json:"stageEnabled"`
}

// JenkinsTrigger constructs the JSON necessary to include a Jenkins trigger
Expand Down
6 changes: 6 additions & 0 deletions pipeline/builder/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,9 @@ type Webhook struct {
}

func (whs Webhook) spinnakerStage() {}

// OptionalStageSupport determines if a stage is enabled in the pipeline
type OptionalStageSupport struct {
Expression string `json:"expression"`
Type string `json:"type"`
}
1 change: 1 addition & 0 deletions pipeline/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type Stage struct {
RefID string `yaml:"refId,omitempty"`
ReliesOn []string `yaml:"reliesOn,omitempty"`
Notifications []Notification `yaml:"notifications,omitempty"`
Condition string `yaml:"condition,omitempty"`

// All of the different supported stages, only one may be set
RunJob *RunJobStage `yaml:"runJob,omitempty"`
Expand Down

0 comments on commit 681143a

Please sign in to comment.