class Repository (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CodeCommit.Repository |
![]() | software.amazon.awscdk.services.codecommit.Repository |
![]() | aws_cdk.aws_codecommit.Repository |
![]() | @aws-cdk/aws-codecommit » Repository |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IRepository
, INotification
Provides a CodeCommit Repository.
Example
declare const project: codebuild.PipelineProject;
const repository = new codecommit.Repository(this, 'MyRepository', {
repositoryName: 'MyRepository',
});
const project = new codebuild.PipelineProject(this, 'MyProject');
const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.CodeCommitSourceAction({
actionName: 'CodeCommit',
repository,
output: sourceOutput,
});
const buildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceOutput,
outputs: [new codepipeline.Artifact()], // optional
executeBatchBuild: true, // optional, defaults to false
combineBatchBuildArtifacts: true, // optional, defaults to false
});
new codepipeline.Pipeline(this, 'MyPipeline', {
stages: [
{
stageName: 'Source',
actions: [sourceAction],
},
{
stageName: 'Build',
actions: [buildAction],
},
],
});
Initializer
new Repository(scope: Construct, id: string, props: RepositoryProps)
Parameters
- scope
Construct
- id
string
- props
Repository
Props
Construct Props
Name | Type | Description |
---|---|---|
repository | string | Name of the repository. |
code? | Code | The contents with which to initialize the repository after it has been created. |
description? | string | A description of the repository. |
repositoryName
Type:
string
Name of the repository.
This property is required for all CodeCommit repositories.
code?
Type:
Code
(optional, default: No initialization (create empty repo))
The contents with which to initialize the repository after it has been created.
description?
Type:
string
(optional, default: No description.)
A description of the repository.
Use the description to identify the purpose of the repository.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
repository | string | The ARN of this Repository. |
repository | string | The HTTPS (GRC) clone URL. |
repository | string | The HTTP clone URL. |
repository | string | The SSH clone URL. |
repository | string | The human-visible name of this Repository. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Construct
The construct tree node associated with this construct.
repositoryArn
Type:
string
The ARN of this Repository.
repositoryCloneUrlGrc
Type:
string
The HTTPS (GRC) clone URL.
HTTPS (GRC) is the protocol to use with git-remote-codecommit (GRC).
It is the recommended method for supporting connections made with federated access, identity providers, and temporary credentials.
repositoryCloneUrlHttp
Type:
string
The HTTP clone URL.
repositoryCloneUrlSsh
Type:
string
The SSH clone URL.
repositoryName
Type:
string
The human-visible name of this Repository.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
bind | Returns a source configuration for notification rule. |
grant(grantee, ...actions) | Grant the given principal identity permissions to perform the actions on this repository. |
grant | Grant the given identity permissions to pull this repository. |
grant | Grant the given identity permissions to pull and push this repository. |
grant | Grant the given identity permissions to read this repository. |
notifiy | Defines a CodeStar Notification rule which triggers when a pull request is merged. |
notify(arn, options?) | Create a trigger to notify another service to run actions on repository events. |
notify | Defines a CodeStar Notification rule triggered when the project events specified by you are emitted. Similar to onEvent API. |
notify | Defines a CodeStar Notification rule which triggers when an approval rule is overridden. |
notify | Defines a CodeStar Notification rule which triggers when an approval status is changed. |
notify | Defines a CodeStar Notification rule which triggers when a new branch or tag is created. |
notify | Defines a CodeStar Notification rule which triggers when a branch or tag is deleted. |
notify | Defines a CodeStar Notification rule which triggers when a comment is made on a pull request. |
notify | Defines a CodeStar Notification rule which triggers when a pull request is created. |
notify | Defines a CodeStar Notification rule which triggers when a pull request is merged. |
on | Defines a CloudWatch event rule which triggers when a comment is made on a commit. |
on | Defines a CloudWatch event rule which triggers when a comment is made on a pull request. |
on | Defines a CloudWatch event rule which triggers when a commit is pushed to a branch. |
on | Defines a CloudWatch event rule which triggers for repository events. |
on | Defines a CloudWatch event rule which triggers when a pull request state is changed. |
on | Defines a CloudWatch event rule which triggers when a reference is created (i.e. a new branch/tag is created) to the repository. |
on | Defines a CloudWatch event rule which triggers when a reference is delete (i.e. a branch/tag is deleted) from the repository. |
on | Defines a CloudWatch event rule which triggers when a reference is updated (i.e. a commit is pushed to an existing or new branch) from the repository. |
on | Defines a CloudWatch event rule which triggers when a "CodeCommit Repository State Change" event occurs. |
to | Returns a string representation of this construct. |
static from | Imports a codecommit repository. |
static from |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
bindAsNotificationRuleSource(_scope)
public bindAsNotificationRuleSource(_scope: Construct): NotificationRuleSourceConfig
Parameters
- _scope
Construct
Returns
Returns a source configuration for notification rule.
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantable
- actions
string
Returns
Grant the given principal identity permissions to perform the actions on this repository.
grantPull(grantee)
public grantPull(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant the given identity permissions to pull this repository.
grantPullPush(grantee)
public grantPullPush(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant the given identity permissions to pull and push this repository.
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant the given identity permissions to read this repository.
notifiyOnPullRequestMerged(id, target, options?)
public notifiyOnPullRequestMerged(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when a pull request is merged.
notify(arn, options?)
public notify(arn: string, options?: RepositoryTriggerOptions): Repository
Parameters
- arn
string
— Arn of the resource that repository events will notify. - options
Repository
— Trigger options to run actions.Trigger Options
Returns
Create a trigger to notify another service to run actions on repository events.
notifyOn(id, target, options)
public notifyOn(id: string, target: INotificationRuleTarget, options: RepositoryNotifyOnOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Repository
Notify On Options
Returns
Defines a CodeStar Notification rule triggered when the project events specified by you are emitted. Similar to onEvent
API.
You can also use the methods to define rules for the specific event emitted.
eg: notifyOnPullRequstCreated
.
notifyOnApprovalRuleOverridden(id, target, options?)
public notifyOnApprovalRuleOverridden(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when an approval rule is overridden.
notifyOnApprovalStatusChanged(id, target, options?)
public notifyOnApprovalStatusChanged(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when an approval status is changed.
notifyOnBranchOrTagCreated(id, target, options?)
public notifyOnBranchOrTagCreated(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when a new branch or tag is created.
notifyOnBranchOrTagDeleted(id, target, options?)
public notifyOnBranchOrTagDeleted(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when a branch or tag is deleted.
notifyOnPullRequestComment(id, target, options?)
public notifyOnPullRequestComment(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when a comment is made on a pull request.
notifyOnPullRequestCreated(id, target, options?)
public notifyOnPullRequestCreated(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when a pull request is created.
notifyOnPullRequestMerged(id, target, options?)
public notifyOnPullRequestMerged(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule
Parameters
- id
string
- target
INotification
Rule Target - options
Notification
Rule Options
Returns
Defines a CodeStar Notification rule which triggers when a pull request is merged.
onCommentOnCommit(id, options?)
public onCommentOnCommit(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a comment is made on a commit.
onCommentOnPullRequest(id, options?)
public onCommentOnPullRequest(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a comment is made on a pull request.
onCommit(id, options?)
public onCommit(id: string, options?: OnCommitOptions): Rule
Parameters
- id
string
- options
On
Commit Options
Returns
Defines a CloudWatch event rule which triggers when a commit is pushed to a branch.
onEvent(id, options?)
public onEvent(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers for repository events.
Use
rule.addEventPattern(pattern)
to specify a filter.
onPullRequestStateChange(id, options?)
public onPullRequestStateChange(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a pull request state is changed.
onReferenceCreated(id, options?)
public onReferenceCreated(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a reference is created (i.e. a new branch/tag is created) to the repository.
onReferenceDeleted(id, options?)
public onReferenceDeleted(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a reference is delete (i.e. a branch/tag is deleted) from the repository.
onReferenceUpdated(id, options?)
public onReferenceUpdated(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a reference is updated (i.e. a commit is pushed to an existing or new branch) from the repository.
onStateChange(id, options?)
public onStateChange(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule which triggers when a "CodeCommit Repository State Change" event occurs.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromRepositoryArn(scope, id, repositoryArn)
public static fromRepositoryArn(scope: Construct, id: string, repositoryArn: string): IRepository
Parameters
- scope
Construct
- id
string
- repositoryArn
string
— (e.g.arn:aws:codecommit:us-east-1:123456789012:MyDemoRepo
).
Returns
Imports a codecommit repository.
static fromRepositoryName(scope, id, repositoryName)
public static fromRepositoryName(scope: Construct, id: string, repositoryName: string): IRepository
Parameters
- scope
Construct
- id
string
- repositoryName
string
Returns