How to define context variables for a Job - 6.5

Talend Open Studio for Data Integration User Guide

Talend Open Studio for Data Integration
Design and Development
Talend Studio

You can define context variables for a particular Job in two ways:

How to define context variables in the Contexts view

The Contexts view is positioned among the configuration tabs below design workspace.

The Contexts tab view shows all of the variables that have been defined in the current Job and context variables imported into the current Job.

From this view, you can manage your built-in variables:

  • Create and manage built-in contexts.

  • Create, edit and delete built-in variables.

  • Reorganize the context variables.

  • Add built-in context variables to the Repository.

  • Import variables from a Repository context source for use in the current Job.

  • Edit Repository-stored context variables and update the changes to the Repository.

  • Remove imported Repository variables from the current Job.

The following example will demonstrate how to define two contexts named Prod and Test and a set of variables - host, port, database, username, password, and table_name - under the two contexts for a Job.

Defining contexts
  1. Open the Job in the design workspace.

  2. Select Window > Show view > Talend > Contexts to open the Contexts view in the Integration perspective.

  3. Click the [+] button at the top right corner.

    The [Configure Contexts] dialog box opens and a context named Default is created by default.

  4. Select the default context and click Edit to rename it, Prod in this example. Click OK.

  5. In the open dialog box, click New... and enter Test in the [New Context] dialog box, click OK.

  6. Select the check box preceding the context you want to set as the default context.

    You can also set the default context by selecting the context name from the Default context environment list in the Contexts tab view.

    If needed, move a context up or down by selecting it and clicking the Up or Down button.

    In this example, set Test as the default context and move it up.

  7. Click OK to validate your context definition and close the dialog box.

    The newly created contexts are shown in the context variables table of the Contexts view.

  8. Repeat the above steps to create as many new contexts as needed.

    If you do not want to define the values of each new context from scratch, you can create the first context and define all its values as when you create a new one all the parameters of the context selected as default are copied to the new context. You can then modify the values of the new context as needed.

Defining variables
  1. Click the [+] button at the bottom of the Contexts view to add lines in the table.

  2. Click in the Name field and enter the name of the variable you are creating.

    Name the first variable host for this example.

  3. From the Type list, select the type of the variable.

  4. If needed, click in the Comment field and enter a comment to describe the variable.

  5. Click in the Value field and enter the variable value under each context.

    For different variable types, the Value field appear slightly different when you click in it and functions differently:


    Value field

    Default value

    String (default type)

    Editable text field



    Drop-down list box with two options: true and false

    Character, Double, Integer, Long, Short, Object, BigDecimal

    Editable text field


    Editable text field, with a button to open the [Select Date & Time] dialog box.


    Editable text field, with a button to open the [Open] dialog box for file selection.


    Editable text field, with a button to open the [Browse for Folder] dialog box for folder selection.

    List of Value

    Editable text field, with a button to open the [Configure Values] dialog box for list creation and configuration.



    Editable text field; text entered appears encrypted.


    Be sure to enclose the value of a string type of variable between double quotation marks if it has a leading and/or a trailing double quotation mark as part of the variable value. In any case, it will do no harm if you enclose the values of string type of variables between double quotation marks.

  6. If needed, select the check box next to the variable of interest and enter the prompt message in the corresponding Prompt field. This allows you to see a prompt for the variable value and to edit it at the execution time.

    You can show/hide a Prompt column of the table by clicking the black right/left pointing triangle next to the relevant context name.

  7. Repeat the above steps to define all the variables for the different contexts.

    • port, type String,

    • database, type String,

    • username, type String,

    • password, type Password,

    • table_name, type String.

    All the variables created and their values under different contexts are displayed in the table and are ready for use in your Job. You can further edit the variables in this view if needed.

    You can also add a built-in context variable to the Repository to make it reusable across different Jobs. For more information, see How to add a built-in context variable to the Repository.

How to define variables from the Component view

The quickest way to create a single context variable is to use the F5 key from the Component view. The following example demonstrates how to create a context variable while configuring a file path for a component in a Job.

  1. On the relevant Component view, place your cursor in the field you want to parameterize.

  2. Press F5 to display the [New Context Parameter] dialog box:

  3. Give a Name to this new variable, fill in the Comment field if needed, and choose the Type.

  4. Enter a Prompt to be displayed to confirm the use of this variable in the current Job execution (generally used for test purpose only), select the Prompt for value check box to display the prompt message and an editable value field at the execution time.

  5. If you filled in a value already in the corresponding properties field, this value is displayed in the Default value field. Else, type in the default value you want to use for one context.

  6. Click Finish to validate.

  7. Go to the Contexts view tab. Notice that the context variables tab lists the newly created variables.

    The newly created variables are listed in the Contexts view.


The variable name should follow some typing rules and should not contain any forbidden characters, such as space character.

The variable created this way is automatically stored in all existing contexts, but you can subsequently change the value independently in each context. For more information on how to create or edit a context, see Defining contexts.