Pipeline

class aws_cdk.aws_codepipeline.Pipeline(scope, id, *, artifact_bucket=None, cross_region_replication_buckets=None, pipeline_name=None, restart_execution_on_update=None, role=None, stages=None)

Bases: aws_cdk.core.Resource

An AWS CodePipeline pipeline with its associated IAM role and S3 bucket.

Example:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
# create a pipeline
pipeline = Pipeline(self, "Pipeline")

# add a stage
source_stage = pipeline.add_stage(name="Source")

# add a source action to the stage
source_stage.add_action(codepipeline_actions.CodeCommitSourceAction(
    action_name="Source",
    output_artifact_name="SourceArtifact",
    repository=repo
))
__init__(scope, id, *, artifact_bucket=None, cross_region_replication_buckets=None, pipeline_name=None, restart_execution_on_update=None, role=None, stages=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • artifact_bucket (Optional[IBucket]) – The S3 bucket used by this Pipeline to store artifacts. Default: - A new S3 bucket will be created.

  • cross_region_replication_buckets (Optional[Mapping[str, IBucket]]) – A map of region to S3 bucket name used for cross-region CodePipeline. For every Action that you specify targeting a different region than the Pipeline itself, if you don’t provide an explicit Bucket for that region using this property, the construct will automatically create a Stack containing an S3 Bucket in that region. Default: - None.

  • pipeline_name (Optional[str]) – Name of the pipeline. Default: - AWS CloudFormation generates an ID and uses that for the pipeline name.

  • restart_execution_on_update (Optional[bool]) – Indicates whether to rerun the AWS CodePipeline pipeline after you update it. Default: false

  • role (Optional[IRole]) – The IAM role to be assumed by this Pipeline. Default: a new IAM role will be created.

  • stages (Optional[List[StageProps]]) – The list of Stages, in order, to create this Pipeline with. You can always add more Stages later by calling {@link Pipeline#addStage}. Default: - None.

Return type

None

Methods

add_stage(*, placement=None, stage_name, actions=None)

Creates a new Stage, and adds it to this Pipeline.

Parameters
  • placement (Optional[StagePlacement]) –

  • stage_name (str) – The physical, human-readable name to assign to this Pipeline Stage.

  • actions (Optional[List[IAction]]) – The list of Actions to create this Stage with. You can always add more Actions later by calling {@link IStage#addAction}.

return :rtype: IStage :return: the newly created Stage

add_to_role_policy(statement)

Adds a statement to the pipeline role.

Parameters

statement (PolicyStatement) –

Return type

None

on_event(id, *, description=None, event_pattern=None, rule_name=None, target=None)

Defines an event rule triggered by this CodePipeline.

Parameters
  • id (str) – Identifier for this event handler.

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Optional[EventPattern]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type

Rule

on_state_change(id, *, description=None, event_pattern=None, rule_name=None, target=None)

Defines an event rule triggered by the “CodePipeline Pipeline Execution State Change” event emitted from this pipeline.

Parameters
  • id (str) – Identifier for this event handler.

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Optional[EventPattern]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type

Rule

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

artifact_bucket

Bucket used to store output artifacts.

Return type

IBucket

cross_region_support

Returns all of the {@link CrossRegionSupportStack}s that were generated automatically when dealing with Actions that reside in a different region than the Pipeline itself.

stability :stability: experimental

Return type

Mapping[str, CrossRegionSupport]

node

The construct tree node associated with this construct.

Return type

ConstructNode

pipeline_arn

ARN of this pipeline.

Return type

str

pipeline_name

The name of the pipeline.

Return type

str

pipeline_version

The version of the pipeline.

attribute: :attribute:: true

Return type

str

role

The IAM role AWS CodePipeline will use to perform actions or assume roles for actions with a more specific IAM role.

Return type

IRole

stack

The stack in which this resource is defined.

Return type

Stack

stage_count

Get the number of Stages in this Pipeline.

Return type

Union[int, float]

stages

Returns the stages that comprise the pipeline.

Note: the returned array is a defensive copy, so adding elements to it has no effect. Instead, use the {@link addStage} method if you want to add more stages to the pipeline.

Return type

List[IStage]

Static Methods

classmethod from_pipeline_arn(scope, id, pipeline_arn)

Import a pipeline into this app.

Parameters
  • scope (Construct) – the scope into which to import this pipeline.

  • id (str) – the logical ID of the returned pipeline construct.

  • pipeline_arn (str) – The ARN of the pipeline (e.g. arn:aws:codepipeline:us-east-1:123456789012:MyDemoPipeline).

Return type

IPipeline

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool