CommandsActionProps Struct
Construction properties of the CommandsAction.
| Source | aws-codepipeline-actions/lib/commands/commands-action.ts |
|---|---|
| Type last changed |
Example
declare const sourceArtifact: codepipeline.Artifact;
declare const outputArtifact: codepipeline.Artifact;
const commandsAction = new codepipeline_actions.CommandsAction({
actionName: 'Commands',
commands: [
'export MY_OUTPUT=my-key',
],
input: sourceArtifact,
output: outputArtifact,
outputVariables: ['MY_OUTPUT', 'CODEBUILD_BUILD_ID'], // CODEBUILD_BUILD_ID is a variable defined by CodeBuild
});
// Deploy action
const deployAction = new codepipeline_actions.S3DeployAction({
actionName: 'DeployAction',
extract: true,
input: outputArtifact,
bucket: new s3.Bucket(this, 'DeployBucket'),
objectKey: commandsAction.variable('MY_OUTPUT'), // the variable emitted by the Commands action
});
# source_artifact: codepipeline.Artifact
# output_artifact: codepipeline.Artifact
commands_action = codepipeline_actions.CommandsAction(
action_name="Commands",
commands=["export MY_OUTPUT=my-key"
],
input=source_artifact,
output=output_artifact,
output_variables=["MY_OUTPUT", "CODEBUILD_BUILD_ID"]
)
# Deploy action
deploy_action = codepipeline_actions.S3DeployAction(
action_name="DeployAction",
extract=True,
input=output_artifact,
bucket=s3.Bucket(self, "DeployBucket"),
object_key=commands_action.variable("MY_OUTPUT")
)
Artifact sourceArtifact;
Artifact outputArtifact;
CommandsAction commandsAction = CommandsAction.Builder.create()
.actionName("Commands")
.commands(List.of("export MY_OUTPUT=my-key"))
.input(sourceArtifact)
.output(outputArtifact)
.outputVariables(List.of("MY_OUTPUT", "CODEBUILD_BUILD_ID"))
.build();
// Deploy action
S3DeployAction deployAction = S3DeployAction.Builder.create()
.actionName("DeployAction")
.extract(true)
.input(outputArtifact)
.bucket(new Bucket(this, "DeployBucket"))
.objectKey(commandsAction.variable("MY_OUTPUT"))
.build();
// Install: dotnet add package Amazon.CDK.Lib
Artifact sourceArtifact;
Artifact outputArtifact;
var commandsAction = new CommandsAction(new CommandsActionProps {
ActionName = "Commands",
Commands = new [] { "export MY_OUTPUT=my-key" },
Input = sourceArtifact,
Output = outputArtifact,
OutputVariables = new [] { "MY_OUTPUT", "CODEBUILD_BUILD_ID" }
});
// Deploy action
var deployAction = new S3DeployAction(new S3DeployActionProps {
ActionName = "DeployAction",
Extract = true,
Input = outputArtifact,
Bucket = new Bucket(this, "DeployBucket"),
ObjectKey = commandsAction.Variable("MY_OUTPUT")
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var sourceArtifact Artifact
var outputArtifact Artifact
commandsAction := codepipeline_actions.NewCommandsAction(&CommandsActionProps{
ActionName: jsii.String("Commands"),
Commands: []*string{
jsii.String("export MY_OUTPUT=my-key"),
},
Input: sourceArtifact,
Output: outputArtifact,
OutputVariables: []*string{
jsii.String("MY_OUTPUT"),
jsii.String("CODEBUILD_BUILD_ID"),
},
})
// Deploy action
deployAction := codepipeline_actions.NewS3DeployAction(&S3DeployActionProps{
ActionName: jsii.String("DeployAction"),
Extract: jsii.Boolean(true),
Input: outputArtifact,
Bucket: s3.NewBucket(this, jsii.String("DeployBucket")),
ObjectKey: commandsAction.Variable(jsii.String("MY_OUTPUT")),
})
Properties
Note that Action names must be unique within a single Stage.
commandsstring[]commandstyping.List[str]commandsList<String>Commandsstring[]Commands*[]*string required #All formats are supported except multi-line formats.
The length of the commands array must be between 1 and 50.
extraInputsoptionalArtifact[]extra_inputsoptionaltyping.List[Artifact]extraInputsoptionalList<Artifact>ExtraInputsoptionalArtifact[]ExtraInputsoptional*[]Artifact #Default: no extra inputs
outputoptionalArtifactoutputoptionalArtifactoutputoptionalArtifactOutputoptionalArtifactOutputoptionalArtifact #Default: no output artifact
You can filter files that you want to export as the output artifact for the action.
example
new codepipeline.Artifact('CommandsArtifact', ['my-dir/**']);
outputVariablesoptionalstring[]output_variablesoptionaltyping.List[str]outputVariablesoptionalList<String>OutputVariablesoptionalstring[]OutputVariablesoptional*[]*string #Default: No output variables are exported
These variables can be referenced in other actions by using the variable method of this class.
Default: a new Role will be generated
notes
The Pipeline's Role will assume this Role (the required permissions for that will be granted automatically) right before executing this Action. This Action will be passed into your IAction.bind method in the ActionBindOptions.role property.
runOrderoptionalnumberrun_orderoptionalint | floatrunOrderoptionalNumberRunOrderoptionaldoubleRunOrderoptional*float64 = 1 #RunOrder determines the relative order in which multiple Actions in the same Stage execute.
variablesNamespaceoptionalstringvariables_namespaceoptionalstrvariablesNamespaceoptionalStringVariablesNamespaceoptionalstringVariablesNamespaceoptional*string #Default: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set