diff --git a/templates/assets/cloudformation/artifact-pipeline.yml b/templates/assets/cloudformation/artifact-pipeline.yml index f855fc05..9036fd73 100644 --- a/templates/assets/cloudformation/artifact-pipeline.yml +++ b/templates/assets/cloudformation/artifact-pipeline.yml @@ -11,6 +11,16 @@ Parameters: SourceBranch: Type: String Description: Branch to trigger pipeline + {{if eq .SourceProvider "S3" -}} + SourceBucket: + Type: String + Description: Source Bucket + Default: "" + SourceObjectKey: + Type: String + Description: Source Object Key + Default: "" + {{- end}} {{if eq .SourceProvider "GitHub" -}} GitHubToken: NoEcho: true @@ -90,6 +100,10 @@ Resources: CodeDeployBucket: {{ .CodeDeployBucket }} SourceProvider: {{ .SourceProvider }} SourceRepo: !Ref SourceRepo + {{if eq .SourceProvider "S3" -}} + SourceBucket: !Ref SourceBucket + SourceObjectKey: !Ref SourceObjectKey + {{- end}} {{if eq .EnableAcptStage "true" -}} AcptEnv: {{ .AcptEnv }} {{- end}} @@ -103,7 +117,7 @@ Resources: AcptCloudFormationRoleArn: {{ .AcptCloudFormationRoleArn }} {{- end}} {{if eq .EnableProdStage "true" -}} - ProdCloudFormationRoleArn: {{ .ProdCloudFormationRoleArn }} + ProdCloudFormationRoleArn: {{ .ProdCloudFormationRoleArn }} {{- end}} Tags: - Key: mu:name @@ -130,6 +144,10 @@ Resources: SourceProvider: {{ .SourceProvider }} SourceRepo: !Ref SourceRepo SourceBranch: !Ref SourceBranch + {{if eq .SourceProvider "S3" -}} + SourceBucket: !Ref SourceBucket + SourceObjectKey: !Ref SourceObjectKey + {{- end}} {{if eq .SourceProvider "GitHub" -}} GitHubToken: !Ref GitHubToken {{- end}} diff --git a/workflows/pipeline_upsert.go b/workflows/pipeline_upsert.go index 00bb0a0b..fba441a1 100644 --- a/workflows/pipeline_upsert.go +++ b/workflows/pipeline_upsert.go @@ -252,9 +252,23 @@ func (workflow *pipelineWorkflow) pipelineCatalogUpserter(namespace string, pipe productParams := make(map[string]string) productParams["ServiceName"] = workflow.serviceName - productParams["SourceBranch"] = workflow.codeBranch productParams["SourceRepo"] = pipeline.Source.Repo - productParams["GitHubToken"] = params["GitHubToken"] + + if workflow.codeBranch != "" { + productParams["SourceBranch"] = workflow.codeBranch + } else { + productParams["SourceBranch"] = pipeline.Source.Branch + } + + if pipeline.Source.Provider == "GitHub" { + productParams["GitHubToken"] = params["GitHubToken"] + } + + if pipeline.Source.Provider == "S3" { + repoParts := strings.Split(pipeline.Source.Repo, "/") + productParams["SourceBucket"] = repoParts[0] + productParams["SourceObjectKey"] = strings.Join(repoParts[1:], "/") + } return catalogProvisioner.UpsertProvisionedProduct(stack.Outputs["ProductId"], pipeline.Catalog.Version, fmt.Sprintf("%s-%s", namespace, workflow.serviceName), productParams) }