Skip to content

Commit 61dd938

Browse files
authored
Merge pull request #407 from stelligent/issue-406
Issue 406
2 parents d29f7ad + 9def66b commit 61dd938

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

templates/assets/cloudformation/artifact-pipeline.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ Parameters:
1111
SourceBranch:
1212
Type: String
1313
Description: Branch to trigger pipeline
14+
{{if eq .SourceProvider "S3" -}}
15+
SourceBucket:
16+
Type: String
17+
Description: Source Bucket
18+
Default: ""
19+
SourceObjectKey:
20+
Type: String
21+
Description: Source Object Key
22+
Default: ""
23+
{{- end}}
1424
{{if eq .SourceProvider "GitHub" -}}
1525
GitHubToken:
1626
NoEcho: true
@@ -90,6 +100,10 @@ Resources:
90100
CodeDeployBucket: {{ .CodeDeployBucket }}
91101
SourceProvider: {{ .SourceProvider }}
92102
SourceRepo: !Ref SourceRepo
103+
{{if eq .SourceProvider "S3" -}}
104+
SourceBucket: !Ref SourceBucket
105+
SourceObjectKey: !Ref SourceObjectKey
106+
{{- end}}
93107
{{if eq .EnableAcptStage "true" -}}
94108
AcptEnv: {{ .AcptEnv }}
95109
{{- end}}
@@ -103,7 +117,7 @@ Resources:
103117
AcptCloudFormationRoleArn: {{ .AcptCloudFormationRoleArn }}
104118
{{- end}}
105119
{{if eq .EnableProdStage "true" -}}
106-
ProdCloudFormationRoleArn: {{ .ProdCloudFormationRoleArn }}
120+
ProdCloudFormationRoleArn: {{ .ProdCloudFormationRoleArn }}
107121
{{- end}}
108122
Tags:
109123
- Key: mu:name
@@ -130,6 +144,10 @@ Resources:
130144
SourceProvider: {{ .SourceProvider }}
131145
SourceRepo: !Ref SourceRepo
132146
SourceBranch: !Ref SourceBranch
147+
{{if eq .SourceProvider "S3" -}}
148+
SourceBucket: !Ref SourceBucket
149+
SourceObjectKey: !Ref SourceObjectKey
150+
{{- end}}
133151
{{if eq .SourceProvider "GitHub" -}}
134152
GitHubToken: !Ref GitHubToken
135153
{{- end}}

workflows/pipeline_upsert.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,23 @@ func (workflow *pipelineWorkflow) pipelineCatalogUpserter(namespace string, pipe
252252

253253
productParams := make(map[string]string)
254254
productParams["ServiceName"] = workflow.serviceName
255-
productParams["SourceBranch"] = workflow.codeBranch
256255
productParams["SourceRepo"] = pipeline.Source.Repo
257-
productParams["GitHubToken"] = params["GitHubToken"]
256+
257+
if workflow.codeBranch != "" {
258+
productParams["SourceBranch"] = workflow.codeBranch
259+
} else {
260+
productParams["SourceBranch"] = pipeline.Source.Branch
261+
}
262+
263+
if pipeline.Source.Provider == "GitHub" {
264+
productParams["GitHubToken"] = params["GitHubToken"]
265+
}
266+
267+
if pipeline.Source.Provider == "S3" {
268+
repoParts := strings.Split(pipeline.Source.Repo, "/")
269+
productParams["SourceBucket"] = repoParts[0]
270+
productParams["SourceObjectKey"] = strings.Join(repoParts[1:], "/")
271+
}
258272

259273
return catalogProvisioner.UpsertProvisionedProduct(stack.Outputs["ProductId"], pipeline.Catalog.Version, fmt.Sprintf("%s-%s", namespace, workflow.serviceName), productParams)
260274
}

0 commit comments

Comments
 (0)