Class BuildSpec
BuildSpec for CodeBuild projects.
Namespace: Amazon.CDK.AWS.CodeBuild
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class BuildSpec : DeputyBase
Syntax (vb)
Public MustInherit Class BuildSpec Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.CodeBuild;
var codebuildProject = new Project(this, "Project", new ProjectProps {
ProjectName = "MyTestProject",
BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
{ "version", "0.2" },
{ "phases", new Dictionary<string, IDictionary<string, string[]>> {
{ "build", new Struct {
Commands = new [] { "echo \"Hello, CodeBuild!\"" }
} }
} }
})
});
var task = new CodeBuildStartBuild(this, "Task", new CodeBuildStartBuildProps {
Project = codebuildProject,
IntegrationPattern = IntegrationPattern.RUN_JOB,
EnvironmentVariablesOverride = new Dictionary<string, BuildEnvironmentVariable> {
{ "ZONE", new BuildEnvironmentVariable {
Type = BuildEnvironmentVariableType.PLAINTEXT,
Value = JsonPath.StringAt("$.envVariables.zone")
} }
}
});
Synopsis
Constructors
| BuildSpec() | BuildSpec for CodeBuild projects. |
Properties
| IsImmediate | Whether the buildspec is directly available or deferred until build-time. |
Methods
| FromAsset(string) | Use the contents of a local file as the build spec string. |
| FromObject(IDictionary<string, object>) | BuildSpec for CodeBuild projects. |
| FromObjectToYaml(IDictionary<string, object>) | Create a buildspec from an object that will be rendered as YAML in the resulting CloudFormation template. |
| FromSourceFilename(string) | Use a file from the source as buildspec. |
| ToBuildSpec(Construct?) | Render the represented BuildSpec. |
Constructors
BuildSpec()
BuildSpec for CodeBuild projects.
protected BuildSpec()
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.CodeBuild;
var codebuildProject = new Project(this, "Project", new ProjectProps {
ProjectName = "MyTestProject",
BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
{ "version", "0.2" },
{ "phases", new Dictionary<string, IDictionary<string, string[]>> {
{ "build", new Struct {
Commands = new [] { "echo \"Hello, CodeBuild!\"" }
} }
} }
})
});
var task = new CodeBuildStartBuild(this, "Task", new CodeBuildStartBuildProps {
Project = codebuildProject,
IntegrationPattern = IntegrationPattern.RUN_JOB,
EnvironmentVariablesOverride = new Dictionary<string, BuildEnvironmentVariable> {
{ "ZONE", new BuildEnvironmentVariable {
Type = BuildEnvironmentVariableType.PLAINTEXT,
Value = JsonPath.StringAt("$.envVariables.zone")
} }
}
});
Properties
IsImmediate
Whether the buildspec is directly available or deferred until build-time.
public abstract bool IsImmediate { get; }
Property Value
Remarks
ExampleMetadata: infused
Methods
FromAsset(string)
Use the contents of a local file as the build spec string.
public static BuildSpec FromAsset(string path)
Parameters
- path string
Returns
Remarks
Use this if you have a local .yml or .json file that you want to use as the buildspec
FromObject(IDictionary<string, object>)
BuildSpec for CodeBuild projects.
public static BuildSpec FromObject(IDictionary<string, object> value)
Parameters
- value IDictionary<string, object>
Returns
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.CodeBuild;
var codebuildProject = new Project(this, "Project", new ProjectProps {
ProjectName = "MyTestProject",
BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
{ "version", "0.2" },
{ "phases", new Dictionary<string, IDictionary<string, string[]>> {
{ "build", new Struct {
Commands = new [] { "echo \"Hello, CodeBuild!\"" }
} }
} }
})
});
var task = new CodeBuildStartBuild(this, "Task", new CodeBuildStartBuildProps {
Project = codebuildProject,
IntegrationPattern = IntegrationPattern.RUN_JOB,
EnvironmentVariablesOverride = new Dictionary<string, BuildEnvironmentVariable> {
{ "ZONE", new BuildEnvironmentVariable {
Type = BuildEnvironmentVariableType.PLAINTEXT,
Value = JsonPath.StringAt("$.envVariables.zone")
} }
}
});
FromObjectToYaml(IDictionary<string, object>)
Create a buildspec from an object that will be rendered as YAML in the resulting CloudFormation template.
public static BuildSpec FromObjectToYaml(IDictionary<string, object> value)
Parameters
- value IDictionary<string, object>
the object containing the buildspec that will be rendered as YAML.
Returns
Remarks
ExampleMetadata: infused
FromSourceFilename(string)
Use a file from the source as buildspec.
public static BuildSpec FromSourceFilename(string filename)
Parameters
- filename string
Returns
Remarks
Use this if you want to use a file different from 'buildspec.yml'`
ToBuildSpec(Construct?)
Render the represented BuildSpec.
public abstract string ToBuildSpec(Construct? scope = null)
Parameters
- scope Construct
Returns
Remarks
ExampleMetadata: infused