Tom Jordahl
09/27/2024, 5:12 PMMarvin
09/27/2024, 5:12 PMrun_shell_script
does not expand environment variables. You need to explicitly set expand_env_vars: true
to allow environment variables to be expanded in your script.
Here's an example configuration to export an environment variable correctly:
yaml
- prefect.deployments.steps.run_shell_script:
id: set-env
script: |
export MY_VAR="my_value"
echo $MY_VAR
stream_output: true
expand_env_vars: true
Adding expand_env_vars: true
ensures that your script can properly use the export
command and other environment variable operations.
For more details, you can refer to the Prefect 2.x documentation.
If you have further questions or run into issues, feel free to ask!Tom Jordahl
09/27/2024, 5:15 PM- prefect.deployments.steps.run_shell_script:
id: clone_vgt
stream_output: true
script: |
export BRANCH=${BRANCH:-}
Marvin
09/27/2024, 5:15 PMexport
command is not found, typically arises because the default shell or environment in which the script is being run does not recognize the export
command.
Here's a solution to ensure that the script runs in a compatible shell (like bash):
yaml
- prefect.deployments.steps.run_shell_script:
id: clone_vgt
stream_output: true
script: |
#!/bin/bash
export BRANCH=${BRANCH:-}
shell: /bin/bash
In this example, I've explicitly set the shell as /bin/bash
by adding a shebang line (#!/bin/bash
) and specifying the shell
parameter. This ensures that your script runs in the bash shell, which supports the export
command.
If you want to explore more about this, here's the Prefect 2.x documentation.
Feel free to ask if you have any more questions!