On the Workflow Parameters tab, you can assign a value to a variable or replace the value of a parameter for all nodes in the current workflow. This topic describes how to configure a workflow parameter. In this example, the value of the ReplaceMe parameter is replaced with ReplaceMe123 for all nodes in a manually triggered workflow.
Prerequisites
- A manually triggered workflow is created. For more information, see Create a workflow.
- An ODPS SQL node, a Shell node, and a batch synchronization node that is configured by using the codeless UI are created. For more information, see Create an ODPS SQL node, Create a Shell node, and Configure a batch synchronization node by using the codeless UI.
Precautions
- ODPS SQL node
Go to the configuration tab of a node and click Properties in the right-side navigation pane. In the Parameters section of the Properties tab, assign aaa to the x parameter. When the node is run, the value of the x parameter is replaced with y1. You can use ${x} to reference the workflow parameter in the code.
- Shell node
Go to the configuration tab of a node and click Properties in the right-side navigation pane. In the Parameters section of the Properties tab, enter $x. When the node is run, the value of the x parameter is replaced with y1. You can use $1 to reference the workflow parameter in the code.
- Batch synchronization node
Go to the configuration tab of a node and click Properties in the right-side navigation pane. In the Parameters section of the Properties tab, assign aaa to the -p"-Dx parameter. When the node is run, the value of the -p"-Dx parameter is replaced with y1. You can use ${x} to reference the workflow parameter in the code.
- Before you use workflow parameters, you must configure the parameters of each single node in a workflow to ensure that each node is run as expected.
- If the value that is assigned to a workflow parameter is inconsistent with the value that is assigned to a node parameter, the value of the workflow parameter overwrites the value of the node parameter.
- Parameter names and values are case-sensitive.
Configure a workflow parameter
- Go to the DataStudio page.
- Log on to the DataWorks console.
- In the left-side navigation pane, click Workspaces.
- In the top navigation bar, select the region where the workspace resides. On the Workspaces page, find the workspace in which you want to create tables, and click DataStudio in the Actions column.
- On the left-side navigation submenu, click the Manually Triggered Workflows icon. Then, double-click a manually triggered workflow.
- On the configuration tab of the workflow, click the Workflow Parameters tab in the right-side navigation pane.
- On the Workflow Parameters tab, enter ReplaceMe in the Parameter Name field and ReplaceMe123 in the Value/Expression field.
If you have not assigned a value to a workflow parameter on the Workflow Parameters tab for a manually triggered workflow, you must assign a value to the workflow parameter every time you run the workflow in the production environment.
- Click Save.
Use workflow parameters
- Go to the configuration tab of the ODPS SQL node and obtain the workflow parameters by referring to the following figure.
- Go to the configuration tab of the Shell node and obtain the workflow parameters by referring to the following figure. Note Make sure that you specify the workflow parameter in the correct format for the Shell node.
- Go to the configuration tab of the batch synchronization node and obtain the workflow parameters by referring to the following figure. The ReplaceMe parameter is assigned the value abc for the sync node. The workflow parameter is specified as ReplaceMe=ReplaceMe123. When the workflow is run, the ReplaceMe parameter is assigned the value ReplaceMe123 for the node, namely pt="ReplaceMe123".Note Make sure that you specify the workflow parameter in the -p"-DParameter name=Parameter value" format for the sync node.
Run the workflow and view the results
- Run the workflow and assign a value to each workflow parameter.
- On the configuration tab of the workflow, click the
icon in the top toolbar.
- In the Enter parameters dialog box, assign a value to the ReplaceMe parameter.
- On the configuration tab of the workflow, click the
- View the result.
- Right-click the ODPS SQL node and select View Log. Then, you can view the value that is assigned to the ReplaceMe parameter for the ODPS SQL node.
- Right-click the Shell node and select View Log. Then, you can view the value that is assigned to the ReplaceMe parameter for the Shell node.
- Right-click the synchronization node and select View Log. Then, you can view the value that is assigned to the ReplaceMe parameter for the synchronization node.
- Right-click the ODPS SQL node and select View Log. Then, you can view the value that is assigned to the ReplaceMe parameter for the ODPS SQL node.