Shell Commands

Note: This feature is available in version 4.17 and later.

Using Shell Commands in a Flow file allows you to use multiple commands in sequence and redirect environment variable commands via grep.

Read more: flow

Shell Command implementation example

First you want to ensure that the environment variables are set correctly in the Flow file.

In the example below, note that the title 'Printing LIQUIBASE_* env vars' is echoed and && env | grep 'LIQUIBASE_"" is chained.

You will also notice that the env output is directed into the grep 'Liquibase_' command:

env | grep 'LIQUIBASE_'

This will allow you to only print the environment variables that match 'LIQUIBASE_'

Chained Command Example in Flow file:

Copy
stages:
    chainedCommandExample:
        actions:
                -type: shell
                    #command: bash -c "echo "Printing Liquibase_* env vars' && env | grep "LIQUIBASE_'"
                    command: echo 'Printing LIQUIBASE_* env vars' && env |grep 'LIQUIBASE_'

Type the following in the CLI to enable both a shell command and the environment variables:

echo 'Printing LIQUIBASE_* env vars' && env | grep 'LIQUIBASE_'

The results show the env command directed into grep prints only LIQUIBASE_ items.

Command Format

The correct command format within a Flow file is essential to run liquibase flow successfully.

chain commands include bash -c in front of the double quoted command "echo 'Printing LIQUIBASE_* env vars' && env | grep 'LIQUIBASE_'" which tells the machine to run a completely new shell. If you need to quote something inside of the command, use single quotes to distinguish the inside from the outside of the shell command in double quotes.

Chain command example:

bash -c "echo "Printing Liquibase_* env vars' && env | grep "LIQUIBASE_'"

Once that is added to the Flow file, run the liquibase flow command.

liquibase flow --flow-file=flows/(your flow file title here).yaml

The shell bash commits successfully and all environment variables display as intended.

Related links