diff --git a/internal/pkg/manifest/pipeline.go b/internal/pkg/manifest/pipeline.go index 0969ad1ac14..6fde3f1c076 100644 --- a/internal/pkg/manifest/pipeline.go +++ b/internal/pkg/manifest/pipeline.go @@ -230,6 +230,18 @@ func UnmarshalPipeline(in []byte) (*PipelineManifest, error) { return nil, errors.New("unexpected error occurs while unmarshalling pipeline.yml") } +// IsCodeStarConnection indicates to the manifest if this source requires a CSC connection. +func (s Source) IsCodeStarConnection() bool { + switch s.ProviderName { + case GithubProviderName: + return true + case BitbucketProviderName: + return true + default: + return false + } +} + func validateVersion(pm *PipelineManifest) (PipelineSchemaMajorVersion, error) { switch pm.Version { case Ver1: diff --git a/site/content/docs/concepts/pipelines.md b/site/content/docs/concepts/pipelines.md index d9ec83f7cd0..4dc053cf405 100644 --- a/site/content/docs/concepts/pipelines.md +++ b/site/content/docs/concepts/pipelines.md @@ -74,6 +74,8 @@ source: properties: branch: main repository: https://github.com/kohidave/demo-api-frontend + # Optional: specify the name of an existing CodeStar Connections connection. + # connection_name: a-connection # The deployment section defines the order the pipeline will deploy # to your environments. @@ -90,7 +92,7 @@ stages: There are 3 main parts of this file: the `name` field, which is the name of your CodePipeline, the `source` section, which details the repository and branch to track, and the `stages` section, which lists the environments you want this pipeline to deploy to. You can update this anytime, but you must run `copilot pipeline update` afterwards. -Typically, you'll update this file if you add new environments you want to deploy to, or want to track a different branch. The pipeline manifest is also where you may add a manual approval step before deployment or commands to run tests (see "Adding Tests," below) after deployment. +Typically, you'll update this file if you add new environments you want to deploy to, or want to track a different branch. If you are using CodeStar Connections to connect to your repository and would like to utilize an existing connection rather than let Copilot generate one for you, you may add the connection name here. The pipeline manifest is also where you may add a manual approval step before deployment or commands to run tests (see "Adding Tests," below) after deployment. ### Step 3: Updating the Buildspec (optional) diff --git a/site/content/docs/manifest/pipeline.md b/site/content/docs/manifest/pipeline.md index c4e23b04b2b..4f5ba49b0b8 100644 --- a/site/content/docs/manifest/pipeline.md +++ b/site/content/docs/manifest/pipeline.md @@ -11,6 +11,8 @@ List of all available properties for a Copilot pipeline manifest. properties: branch: main repository: https://github.com//sample-app-frontend + # Optional: specify the name of an existing CodeStar Connections connection. + connection_name: a-connection stages: - @@ -53,6 +55,9 @@ The name of the branch in your repository that triggers the pipeline. The defaul source.properties.`repository` String The URL of your repository. +source.properties.`connection_name` String +The name of an existing CodeStar Connections connection. If omitted, Copilot will generate a connection for you. +
`stages` Array of Maps diff --git a/templates/cicd/pipeline.yml b/templates/cicd/pipeline.yml index 8495353677e..26794903de0 100644 --- a/templates/cicd/pipeline.yml +++ b/templates/cicd/pipeline.yml @@ -15,6 +15,10 @@ source: # has the following properties: repository, branch. properties:{{range $key, $value := .Source.Properties}} {{$key}}: {{$value}}{{end}} + {{- if .Source.IsCodeStarConnection}} + # Optional: specify the name of an existing CodeStar Connections connection. + # connection_name: a-connection + {{- end}} {{$length := len .Stages}}{{if gt $length 0}} # The deployment section defines the order the pipeline will deploy # to your environments.