Defining a variable
You can define variables in two ways:
-
In the
Inputs
section of a workflow action – see To define a variable in the 'Inputs' section -
In the
Steps
section of a workflow action – see To define a variable in the 'Steps' sectionNote
The
Steps
method only works with the CodeCatalyst build, test, and GitHub Actions actions, because these are the only actions that include aSteps
section.
For examples, see Examples of variables.
For more information about variables, see Using variables in workflows.
- Visual
-
To define a variable in the 'Inputs' section (visual editor)
Open the CodeCatalyst console at https://codecatalyst.aws/
. -
Choose your project.
-
In the navigation pane, choose CI/CD, and then choose Workflows.
-
Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.
-
Choose Edit.
-
Choose Visual.
-
In the workflow diagram, choose the action where you want to set the variable.
-
Choose Inputs.
-
In Variables - optional, choose Add variable, and then do the following:
Specify a sequence of name/value pairs that define the input variables that you want to make available to the action. Variable names are limited to alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_). Spaces are not allowed. You cannot use quotation marks to enable special characters and spaces in variable names.
For more information about variables, including examples, see Using variables in workflows.
-
(Optional) Choose Validate to validate the workflow's YAML code before committing.
-
Choose Commit, enter a commit message, and choose Commit again.
- YAML
-
To define a variable in the 'Inputs' section (YAML editor)
Open the CodeCatalyst console at https://codecatalyst.aws/
. -
Choose your project.
-
In the navigation pane, choose CI/CD, and then choose Workflows.
-
Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.
-
Choose Edit.
-
Choose YAML.
-
In a workflow action, add code similar to the following:
action-name
: Inputs: Variables: - Name:variable-name
Value:variable-value
For more examples, see Examples of variables. For more information, see the Workflow YAML definition for your action.
-
(Optional) Choose Validate to validate the workflow's YAML code before committing.
-
Choose Commit, enter a commit message, and choose Commit again.
- Visual
-
To define a variable in the 'Steps' section (visual editor)
Open the CodeCatalyst console at https://codecatalyst.aws/
. -
Choose your project.
-
In the navigation pane, choose CI/CD, and then choose Workflows.
-
Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.
-
Choose Edit.
-
Choose Visual.
-
In the workflow diagram, choose the action where you want to set the variable.
-
Choose Configuration.
-
In Shell commands or GitHub Actions YAML, whichever is available, define a variable in the action's
Steps
, either explicitly or implicitly.-
To define the variable explicitly, include it in a bash command directly to the
Steps
section. -
To define a variable implicitly, specify it in a file that's referenced in the action's
Steps
section.For examples, see Examples of variables. For more information, see the Workflow YAML definition for the action.
-
-
(Optional) Choose Validate to validate the workflow's YAML code before committing.
-
Choose Commit, enter a commit message, and choose Commit again.
- YAML
-
To define a variable in the 'Steps' section (YAML editor)
Open the CodeCatalyst console at https://codecatalyst.aws/
. -
Choose your project.
-
In the navigation pane, choose CI/CD, and then choose Workflows.
-
Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.
-
Choose Edit.
-
Choose YAML.
-
In a workflow action, define a variable in the action's
Steps
section, either explicitly or implicitly.-
To define the variable explicitly, include it in a bash command directly to the
Steps
section. -
To define a variable implicitly, specify it in a file that's referenced in the action's
Steps
section.For examples, see Examples of variables. For more information, see the Workflow YAML definition for the action.
-
-
(Optional) Choose Validate to validate the workflow's YAML code before committing.
-
Choose Commit, enter a commit message, and choose Commit again.