In this tutorial, I would like to introduce a new topic - How to override context params when deploy talend job.
In general, there are two method
config via file.
config by passing parameter in shell script.
Before going further with these two method, I would like to establish a list of context variable and write a small tJava code to print out these context variables.
Variable Name
Variable Type
Value
var_1
String
var_1_original_content
_var_2
String
var_2_original_content
var_3
Password
password
var_4
int - Integer
1
var_5
float - Float
2.2
var_6
double - Double
3.3
var_7
Date
2023-05-11 00:00:00
Then, I create a new tJava component with the following content.
Now, I build job, choose Override parameter’s value, for quick value defining, I choose Value from selected
context, and Finish. A zip file will be generated and it’s ready to execute.
After you extract the zip file, you gonna see file directory tree like this.
To execute the job, in my case, you need to run the following command. And, as you can see, our context parameters has been printed well.
Now, we are ready to go the main part - Config runtime parameters via file & executable scripts.
I. Config with file.properties
Open Default.properties with your your favorite text editor and edit this file to update context params.
At this step, it’s important to escape special character if you play with datetime type. In my case, it’s var_7.
II. Config with executable scripts (.bat, .ps1, .sh)
This is my content of files
etl_01_test_override_context_params_run.ps1
$args will pass all arguments to running script.
etl_01_test_override_context_params_run.sh
$@ similar to $args but in shell script, it will pass all arguments to running script.
To override context parameters, I just need to add --context_param var_1=var_1_value when execute the script. For example