Skip to content
v2.274.0

RuleProps Struct ​

Properties for defining a CodePipeline Rule.

Example ​

ts
declare const sourceAction: codepipeline_actions.CodeStarConnectionsSourceAction;
declare const buildAction: codepipeline_actions.CodeBuildAction;

new codepipeline.Pipeline(this, 'Pipeline', {
  pipelineType: codepipeline.PipelineType.V2,
  stages: [
    {
      stageName: 'Source',
      actions: [sourceAction],
    },
    {
      stageName: 'Build',
      actions: [buildAction],
      // BeforeEntry condition - checks before entering the stage
      beforeEntry: {
        conditions: [{
          rules: [ new codepipeline.Rule({
            name: 'LambdaCheck',
            provider: 'LambdaInvoke',
            version: '1',
            configuration: {
              FunctionName: 'LambdaFunctionName',
            },
          })],
          result:  codepipeline.Result.FAIL,
        }],
      },
      // OnSuccess condition - checks after successful stage completion
      onSuccess: {
        conditions: [{
          result: codepipeline.Result.FAIL,
          rules: [new codepipeline.Rule({
            name: 'CloudWatchCheck',
            provider: 'LambdaInvoke',
            version: '1',
            configuration: {
              AlarmName: 'AlarmName1',
              WaitTime: '300', // 5 minutes
              FunctionName: 'funcName2'
            },
          })],
        }],
      },
      // OnFailure condition - handles stage failure
      onFailure: {
        conditions: [{
          result: codepipeline.Result.ROLLBACK,
            rules: [new codepipeline.Rule({
            name: 'RollBackOnFailure',
            provider: 'LambdaInvoke',
            version: '1',
            configuration: {
              AlarmName: 'Alarm',
              WaitTime: '300', // 5 minutes
              FunctionName: 'funcName1'
            },
          })],
        }],
      },
    },
  ],

});

Properties ​

commandsoptionalstring[]commandsoptionaltyping.List[str]commandsoptionalList<String>Commandsoptionalstring[]Commandsoptional*[]*string#
The shell commands to run with your commands rule in CodePipeline.

Default: No commands

All commands are supported except multi-line formats. While CodeBuild logs and permissions are used, you do not need to create any resources in CodeBuild.

configurationoptionaljsonconfigurationoptionalAnyconfigurationoptionalObjectConfigurationoptionalobjectConfigurationoptionalinterface{}#
The action configuration fields for the rule.

Default: No configuration

This can include custom parameters specific to the rule type.

inputArtifactsoptionalstring[]input_artifactsoptionaltyping.List[str]inputArtifactsoptionalList<String>InputArtifactsoptionalstring[]InputArtifactsoptional*[]*string#
The input artifacts fields for the rule, such as specifying an input file for the rule.

Default: No input artifacts

Each string in the array represents an artifact name that this rule will use as input.

nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string#
The name of the rule that is created for the condition.

Default: A unique name will be generated

Must be unique within the pipeline.

example
ts
'VariableCheck'
provideroptionalstringprovideroptionalstrprovideroptionalStringProvideroptionalstringProvideroptional*string#
The rule provider that implements the rule's functionality.

Default: No provider, must be specified if rule is used

example
ts
'DeploymentWindow'
regionoptionalstringregionoptionalstrregionoptionalStringRegionoptionalstringRegionoptional*string#
The AWS Region for the condition associated with the rule.

Default: Pipeline's region

If not specified, uses the pipeline's region.

roleoptionalRoleroleoptionalRoleroleoptionalRoleRoleoptionalRoleRoleoptionalRole#
The IAM role that the rule will use to execute its actions.

Default: A new role will be created

The role must have sufficient permissions to perform the rule's tasks.

versionoptionalstringversionoptionalstrversionoptionalStringVersionoptionalstringVersionoptional*string= '1'#
The version of the rule to use.

Different versions may have different features or behaviors.