Contact Free trial Login

Setting Environment Variables

If you’re deploying multiple applications as a shared resource, do not set any properties in the project properties files. This might cause conflicts among the various applications that share a domain. Instead, set environment variables over the scope of the deployed application, its domain, and other applications under that domain.

Environment variables set in Studio are only used when you deploy using the Mule runtime engine within Studio.

When you deploy applications on-premises, define system properties from the command line when you start the Mule instance or through the wrapper.conf file to use them as environment variables. See Set System Properties for On-premises Deployments for instructions.

Set Environment Variables in Anypoint Studio

Follow these steps:

  1. Open the dropdown menu next to the Play button and select Run Configurations…​.

    run-configurations-1
  2. Select the corresponding Run configuration. If a Run configuration does not exist for your project, you can create one by using the New launch configuration button:

    run-configurations-2
  3. Select the Environment tab, and add the variables you need.

    run-configurations-4

    The environment variables you create are defined at the domain level. These will affect all of the applications associated with that domain when you deploy locally using Studio.

Environment variables defined in Studio only work when you run the application in the Mule runtime engine within Studio. This configuration does not affect design time operations such as DataSense, automatic completion, or validation.

Accessing Environment Variables

To reference an environment variable, regardless of how it was defined, use the following syntax:

${variableName}

For example, if you want to reference the myVar variable that was set in Studio in the previous example, use the following syntax:

<logger message="${myVar}" doc:name="Environment Variable Set in Studio" />

Or, if you want to reference a variable that is defined in the OS, you can simply use the following syntax:

<logger message="${USER}" doc:name="Environment Variable Set in OS" />

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.