Passing variables

Actions

  1. The first action builds the application and saves the log output to logs.txt:

Primary action (always run)Primary action (always run)

  1. In case the build fails, the Local Shell action assigns the content of logs.txt to a variable using export LOGS=$(cat log.txt). The logs are then sent to a Slack channel with $LOGS as the message content:

Conditional actions (run on failure only)Conditional actions (run on failure only)

Warning
Make sure to set the variable to 'Settable', otherwise it will not be possible to change its value.
Hint
The above use case is just an example of a possible workflow configuration. You can simplify it by using the variable $BUDDY_FAILED_ACTION_LOGS instead of manually exporting the logs to a file.

Pipeline runs

You can pass the values of variables between pipeline runs as well. The values can be saved in one run and then used in another one, e.g. you can set a variable with the version type and increment it in every run.

Hint
You can read more about semantic versioning in our dedicated guide.

Pipelines

You can pass a variable between pipelines using the Trigger pipeline action:

  1. Go to the Variables tab in the action details.
  2. Define the name of the variable and the value to pass:

Variables tabVariables tab

Hint
You can assign any variable from the target pipeline as the value.

Resetting

To reset settable variables between pipeline runs, you can add an action with a command that will clear the value of the variable (preferably at the beginning or at the end of the pipeline):

export mySettableEnv=$

Reset variable commandReset variable command

On pipeline start

You can parameterize your run using the Pass arguments action. It will pause the pipeline and wait for your input to proceed:

Pass arguments windowPass arguments window

Last update:
Aug 6, 2024