You can use the Export Service Variables as Env Variables setting to export service variables as environment variables. This setting is available at account, organization, and project levels.
To enable this setting, go to Account Settings > Account Resources > Default Settings > Pipeline, and then expand Pipeline. Next, set the Export Service Variables as Env Variables setting to
Once you enable this setting, a service's variables are available as Bash variables in any Shell Script step in a stage that deploys that service. You can access the service variables like you access any Bash variables. For example, the service variable,
var1 is available for use in a Shell Script step as
When you add a service variable, you can select variables of type String, Secret, or Number.
Let's consider an example where you have added the following service variables:
In your Shell Script step, you can use these service variables as environment variables if you had enabled the Export Service Variables as Env Variables setting.
Shell scripts executing on remote hosts cannot export the correct value if you're using special characters such as
%, and spaces in Bash.
When you run the pipeline, you can see the value of the service variables passed as environment variables.