diff --git a/packages/@aws-cdk/aws-codebuild/lib/source.ts b/packages/@aws-cdk/aws-codebuild/lib/source.ts index 0f47d0a75e754..b4851a63abad3 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/source.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/source.ts @@ -37,7 +37,7 @@ export class NoSource extends BuildSource { * CodeCommit Source definition for a CodeBuild project */ export class CodeCommitSource extends BuildSource { - constructor(private readonly repo: codecommit.Repository) { + constructor(private readonly repo: codecommit.RepositoryRef) { super(); } diff --git a/packages/@aws-cdk/aws-codecommit/lib/repository.ts b/packages/@aws-cdk/aws-codecommit/lib/repository.ts index 75cdeeb886c94..c55aa53c26386 100644 --- a/packages/@aws-cdk/aws-codecommit/lib/repository.ts +++ b/packages/@aws-cdk/aws-codecommit/lib/repository.ts @@ -43,6 +43,10 @@ export abstract class RepositoryRef extends cdk.Construct { /** The human-visible name of this Repository. */ public abstract readonly repositoryName: string; + /** The HTTP clone URL */ + public abstract readonly repositoryCloneUrlHttp: string; + /** The SSH clone URL */ + public abstract readonly repositoryCloneUrlSsh: string; /** * Exports this Repository. Allows the same Repository to be used in 2 different Stacks. @@ -182,6 +186,23 @@ class ImportedRepositoryRef extends RepositoryRef { }); this.repositoryName = props.repositoryName; } + + public get repositoryCloneUrlHttp() { + return this.repositoryCloneUrl('https'); + } + + public get repositoryCloneUrlSsh() { + return this.repositoryCloneUrl('ssh'); + } + + private repositoryCloneUrl(protocol: 'https' | 'ssh'): string { + return new cdk.FnConcat(`${protocol}://git-codecommit.`, + new cdk.AwsRegion(), + '.', + new cdk.AwsURLSuffix(), + '/v1/repos/', + this.repositoryName).toString(); + } } export interface RepositoryProps {