Configuring Environment Variables
This topic describes how to configure and use environment variables.
Application Scenario
Configure job parameters. If a parameter belongs to multiple jobs, you can extract this parameter as an environment variable. Environment variables can be imported and exported.
The roles that can configure workspace environment variables in the simple and enterprise mode are as follows:
Simple mode: Both developers and administrators can create and edit environment variables in a workspace. This mode does not distinguish the development environment from the production environment. Developers can modify environment variables.
Enterprise mode: Only administrators can create or edit environment variables in a workspace.
Importing Environment Variables
This function is available only if the OBS service is available. If OBS is unavailable, variables can be imported from the local PC.
- Log in to the DataArts Studio console by following the instructions in Accessing the DataArts Studio Instance Console.
- On the DataArts Studio console, locate a workspace and click DataArts Factory.
- In the navigation tree on the left, choose Specifications.
- Click Environment Variables. On the Environment Variables page, click Import.
- In the Import Environment Variable dialog box, select an environment variable file from OBS or a local path and the duplicate name policy.
Figure 1 Importing Environment Variables
Exporting Environment Variables
- Log in to the DataArts Studio console by following the instructions in Accessing the DataArts Studio Instance Console.
- On the DataArts Studio console, locate a workspace and click DataArts Factory.
- In the navigation tree on the left, choose Specifications.
- Click Environment Variable. On the Environment Variable page, click Export to export environment variables.
Configuration Method
- Log in to the DataArts Studio console by following the instructions in Accessing the DataArts Studio Instance Console.
- On the DataArts Studio console, locate a workspace and click DataArts Factory.
- In the navigation tree on the left, choose Specifications.
- On the Environment Variable page, set the variables or constants listed in Table 1 and click Save.
The difference between a variable and a constant lies in whether their values need to be reconfigured when they are imported to another workspace or project.
- The value of a variable (such as workspace name) varies depending on the workspace. When exporting a variable from a workspace and import it to another workspace, you must reconfigure its value.
- The value of a constant in different workspaces is the same. When importing a constant to another workspace, you do not need to reconfigure its value.
Figure 2 Configuring environment variables
Table 1 Configuring environment variables Parameter
Mandatory
Description
Parameter
Yes
The parameter name must be unique, consist of 1 to 64 characters, and contain only letters, digits, underscores (_), and hyphens (-).
The parameter name must be in the format set in Configuring Script Variables. For example, if the format set in the script variable definition is ${dlf.}, the parameter name must be set to dlf.xxx.
Value
Yes
Parameter values support constants and EL expressions but do not support system functions. For example, 123 and abc are supported. If the parameter value is a string, add double quotation marks (""), for example, "05".
For details about how to use EL expressions, see Expression Overview.
Description
No
Parameter description
After configuring an environment variable, you can add, edit, or delete it.
- Add: Click Add to add an environment variable.
- Edit: If the parameter value is a constant, change the parameter value in the text box. If the parameter value is an EL expression, click next to the text box to edit the EL expression. Click Save.
- Delete: Click next to the parameter value text box to delete the environment variable.
How-Tos
The configured environment variables can be used in either of the following ways:
- ${Environment variable}
- #{Evn.get("Environment variable")}
Example
Context:
- A job named test has been created in the DataArts Factory module.
- An environment variable has been added. The parameter name is job and the parameter value is 123.
- Open test and drag a Create OBS node from the node library.
- On the Node Properties tab page, configure the node properties.
Figure 3 Configuring parameters for the Create OBS node
- Click Save and then Monitor to monitor the running status of the job.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot