Module: AWSCDK::CodeBuild::IProject

Includes:
AWSCDK::CodeStarNotifications::INotificationRuleSource, EC2::IConnectable, IAM::IGrantable, IResource, Interfaces::AWSCodebuild::IProjectRef
Included in:
Project
Defined in:
code_build/i_project.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'code_build/i_project.rb', line 352

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :grant_principal => { kind: :property, name: "grantPrincipal", is_optional: false },
    :connections => { kind: :property, name: "connections", is_optional: false },
    :project_ref => { kind: :property, name: "projectRef", is_optional: false },
    :project_arn => { kind: :property, name: "projectArn", is_optional: false },
    :project_name => { kind: :property, name: "projectName", is_optional: false },
    :role => { kind: :property, name: "role", is_optional: true },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :bind_as_notification_rule_source => { kind: :method, name: "bindAsNotificationRuleSource", is_optional: false },
    :add_to_role_policy => { kind: :method, name: "addToRolePolicy", is_optional: false },
    :enable_batch_builds => { kind: :method, name: "enableBatchBuilds", is_optional: false },
    :metric => { kind: :method, name: "metric", is_optional: false },
    :metric_builds => { kind: :method, name: "metricBuilds", is_optional: false },
    :metric_duration => { kind: :method, name: "metricDuration", is_optional: false },
    :metric_failed_builds => { kind: :method, name: "metricFailedBuilds", is_optional: false },
    :metric_succeeded_builds => { kind: :method, name: "metricSucceededBuilds", is_optional: false },
    :notify_on => { kind: :method, name: "notifyOn", is_optional: false },
    :notify_on_build_failed => { kind: :method, name: "notifyOnBuildFailed", is_optional: false },
    :notify_on_build_succeeded => { kind: :method, name: "notifyOnBuildSucceeded", is_optional: false },
    :on_build_failed => { kind: :method, name: "onBuildFailed", is_optional: false },
    :on_build_started => { kind: :method, name: "onBuildStarted", is_optional: false },
    :on_build_succeeded => { kind: :method, name: "onBuildSucceeded", is_optional: false },
    :on_event => { kind: :method, name: "onEvent", is_optional: false },
    :on_phase_change => { kind: :method, name: "onPhaseChange", is_optional: false },
    :on_state_change => { kind: :method, name: "onStateChange", is_optional: false },
  }
end

Instance Method Details

#add_to_role_policy(policy_statement) ⇒ void

This method returns an undefined value.

Parameters:



126
127
128
129
# File 'code_build/i_project.rb', line 126

def add_to_role_policy(policy_statement)
  Jsii::Type.check_type(policy_statement, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "policyStatement")
  jsii_call_method("addToRolePolicy", [policy_statement])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

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).

Parameters:



110
111
112
113
# File 'code_build/i_project.rb', line 110

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#bind_as_notification_rule_source(scope) ⇒ AWSCDK::CodeStarNotifications::NotificationRuleSourceConfig

Returns a source configuration for notification rule.

Parameters:

  • scope (Constructs::Construct)

Returns:



119
120
121
122
# File 'code_build/i_project.rb', line 119

def bind_as_notification_rule_source(scope)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  jsii_call_method("bindAsNotificationRuleSource", [scope])
end

#connectionsAWSCDK::EC2::Connections

The network connections associated with this resource.



50
51
52
# File 'code_build/i_project.rb', line 50

def connections()
  jsii_get_property("connections")
end

#enable_batch_buildsAWSCDK::CodeBuild::BatchBuildConfig?

Enable batch builds.

Returns an object contining the batch service role if batch builds could be enabled.



137
138
139
# File 'code_build/i_project.rb', line 137

def enable_batch_builds()
  jsii_call_method("enableBatchBuilds", [])
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



29
30
31
# File 'code_build/i_project.rb', line 29

def env()
  jsii_get_property("env")
end

#grant_principalAWSCDK::IAM::IPrincipal

The principal to grant permissions to.



43
44
45
# File 'code_build/i_project.rb', line 43

def grant_principal()
  jsii_get_property("grantPrincipal")
end

#metric(metric_name, props = nil) ⇒ AWSCDK::CloudWatch::Metric

Returns a CloudWatch metric associated with this build project.

Parameters:

Returns:



144
145
146
147
148
149
# File 'code_build/i_project.rb', line 144

def metric(metric_name, props = nil)
  Jsii::Type.check_type(metric_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricName")
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric", [metric_name, props])
end

#metric_builds(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: sum over 5 minutes

Measures the number of builds triggered.

Units: Count

Valid CloudWatch statistics: Sum

Parameters:

Returns:



160
161
162
163
164
# File 'code_build/i_project.rb', line 160

def metric_builds(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricBuilds", [props])
end

#metric_duration(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: average over 5 minutes

Measures the duration of all builds over time.

Units: Seconds

Valid CloudWatch statistics: Average (recommended), Maximum, Minimum

Parameters:

Returns:



175
176
177
178
179
# File 'code_build/i_project.rb', line 175

def metric_duration(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricDuration", [props])
end

#metric_failed_builds(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: sum over 5 minutes

Measures the number of builds that failed because of client error or because of a timeout.

Units: Count

Valid CloudWatch statistics: Sum

Parameters:

Returns:



190
191
192
193
194
# File 'code_build/i_project.rb', line 190

def metric_failed_builds(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricFailedBuilds", [props])
end

#metric_succeeded_builds(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: sum over 5 minutes

Measures the number of successful builds.

Units: Count

Valid CloudWatch statistics: Sum

Parameters:

Returns:



205
206
207
208
209
# File 'code_build/i_project.rb', line 205

def metric_succeeded_builds(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricSucceededBuilds", [props])
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


14
15
16
# File 'code_build/i_project.rb', line 14

def node()
  jsii_get_property("node")
end

#notify_on(id, target, options) ⇒ AWSCDK::CodeStarNotifications::INotificationRule

Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar to onEvent API.

You can also use the methods notify_on_build_succeeded and notify_on_build_failed to define rules for these specific event emitted.

Parameters:

Returns:



220
221
222
223
224
225
226
# File 'code_build/i_project.rb', line 220

def notify_on(id, target, options)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXN0YXJub3RpZmljYXRpb25zLklOb3RpZmljYXRpb25SdWxlVGFyZ2V0In0=")), "target")
  options = options.is_a?(Hash) ? ::AWSCDK::CodeBuild::ProjectNotifyOnOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZWJ1aWxkLlByb2plY3ROb3RpZnlPbk9wdGlvbnMifQ==")), "options")
  jsii_call_method("notifyOn", [id, target, options])
end

#notify_on_build_failed(id, target, options = nil) ⇒ AWSCDK::CodeStarNotifications::INotificationRule

Defines a CodeStar notification rule which triggers when a build fails.



234
235
236
237
238
239
240
# File 'code_build/i_project.rb', line 234

def notify_on_build_failed(id, target, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXN0YXJub3RpZmljYXRpb25zLklOb3RpZmljYXRpb25SdWxlVGFyZ2V0In0=")), "target")
  options = options.is_a?(Hash) ? ::AWSCDK::CodeStarNotifications::NotificationRuleOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXN0YXJub3RpZmljYXRpb25zLk5vdGlmaWNhdGlvblJ1bGVPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("notifyOnBuildFailed", [id, target, options])
end

#notify_on_build_succeeded(id, target, options = nil) ⇒ AWSCDK::CodeStarNotifications::INotificationRule

Defines a CodeStar notification rule which triggers when a build completes successfully.



248
249
250
251
252
253
254
# File 'code_build/i_project.rb', line 248

def notify_on_build_succeeded(id, target, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXN0YXJub3RpZmljYXRpb25zLklOb3RpZmljYXRpb25SdWxlVGFyZ2V0In0=")), "target")
  options = options.is_a?(Hash) ? ::AWSCDK::CodeStarNotifications::NotificationRuleOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXN0YXJub3RpZmljYXRpb25zLk5vdGlmaWNhdGlvblJ1bGVPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("notifyOnBuildSucceeded", [id, target, options])
end

#on_build_failed(id, options = nil) ⇒ AWSCDK::Events::Rule

Defines an event rule which triggers when a build fails.

Parameters:

Returns:



261
262
263
264
265
266
# File 'code_build/i_project.rb', line 261

def on_build_failed(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("onBuildFailed", [id, options])
end

#on_build_started(id, options = nil) ⇒ AWSCDK::Events::Rule

Defines an event rule which triggers when a build starts.

Parameters:

Returns:



273
274
275
276
277
278
# File 'code_build/i_project.rb', line 273

def on_build_started(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("onBuildStarted", [id, options])
end

#on_build_succeeded(id, options = nil) ⇒ AWSCDK::Events::Rule

Defines an event rule which triggers when a build completes successfully.

Parameters:

Returns:



285
286
287
288
289
290
# File 'code_build/i_project.rb', line 285

def on_build_succeeded(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("onBuildSucceeded", [id, options])
end

#on_event(id, options = nil) ⇒ AWSCDK::Events::Rule

Defines a CloudWatch event rule triggered when something happens with this project.



298
299
300
301
302
303
# File 'code_build/i_project.rb', line 298

def on_event(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("onEvent", [id, options])
end

#on_phase_change(id, options = nil) ⇒ AWSCDK::Events::Rule

Defines a CloudWatch event rule that triggers upon phase change of this build project.



311
312
313
314
315
316
# File 'code_build/i_project.rb', line 311

def on_phase_change(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("onPhaseChange", [id, options])
end

#on_state_change(id, options = nil) ⇒ AWSCDK::Events::Rule

Defines a CloudWatch event rule triggered when the build project state changes.

You can filter specific build status events using an event pattern filter on the build-status detail field:

const rule = project.onStateChange('OnBuildStarted', { target }); rule.addEventPattern({ detail: { 'build-status': [ "IN_PROGRESS", "SUCCEEDED", "FAILED", "STOPPED" ] } });

You can also use the methods on_build_failed and on_build_succeeded to define rules for these specific state changes.

To access fields from the event in the event target input, use the static fields on the StateChangeEvent class.



345
346
347
348
349
350
# File 'code_build/i_project.rb', line 345

def on_state_change(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("onStateChange", [id, options])
end

#project_arnString

The ARN of this Project.

Returns:

  • (String)


64
65
66
# File 'code_build/i_project.rb', line 64

def project_arn()
  jsii_get_property("projectArn")
end

#project_nameString

The human-visible name of this Project.

Returns:

  • (String)


71
72
73
# File 'code_build/i_project.rb', line 71

def project_name()
  jsii_get_property("projectName")
end

#project_refAWSCDK::Interfaces::AWSCodebuild::ProjectReference

A reference to a Project resource.



57
58
59
# File 'code_build/i_project.rb', line 57

def project_ref()
  jsii_get_property("projectRef")
end

#roleAWSCDK::IAM::IRole?

The IAM service Role of this Project.

Undefined for imported Projects.

Returns:



80
81
82
# File 'code_build/i_project.rb', line 80

def role()
  jsii_get_property("role")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



36
37
38
# File 'code_build/i_project.rb', line 36

def stack()
  jsii_get_property("stack")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



91
92
93
94
95
96
# File 'code_build/i_project.rb', line 91

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end