How to set the context for sub-jobs through command-line?

One Star

How to set the context for sub-jobs through command-line?

Let say I have a context group ctxA with three configurations (DEV, UAT, PROD). I also have two jobs - jobA and subJobB. The subJobB is executed by a component tRunJob in jobA. If I run jobA through command-line with parameter "--context=PROD", how to make sure subJobB is also using "PROD" context?

Re: How to set the context for sub-jobs through command-line?

check "transmit whole context" in your tRunJob
One Star

Re: How to set the context for sub-jobs through command-line?

John, the "Transmit whole context" transmits the context group ctxA to the subJobB, not the selection of context "PROD". The context for tRunJob is controled by selecting the item in the dropdown list box for Context in the Basic settings tag and this selection is hard-coded when Talend generates the Java code. This is the code snippet:
currentComponent = "tRunJob_1";
java.util.List<String> paraList_tRunJob_1 = new java.util.ArrayList<String>();
paraList_tRunJob_1.add("--father_pid=" + pid);
paraList_tRunJob_1.add("--root_pid=" + rootPid);
paraList_tRunJob_1.add("--father_node=tRunJob_1");
paraList_tRunJob_1.add("--context=uat");
// for 10589
paraList_tRunJob_1.add("--stat_port=" + portStats);
As you see it is hard-coded as "--context=uat". This is not what I want. What I want is how to make the component tRunJob take what I put in the command-line when run the parent job jboA, such as "--context=PROD".

Re: How to set the context for sub-jobs through command-line?

if you transmit the whole context, all the PROD variables will be copied into the child job-- no matter what group it is configured for-- as long as the variable exists in the father job. I prefer this method of managing contexts, as I only have to change it in once place.
Regardless, you should find a "Context" drop-down in the tRunJob that allows you to choose which context is passed to the child jobs. If you do not see this, please let me know what version of Talend you are using...
One Star

Re: How to set the context for sub-jobs through command-line?

John, it seems that you might not really understand what I want to achieve. Let me explain it in another way:
I'm using Teland Enterprise 4.1.2 and I do see "Context" drop-down in the tRunJob. That is what I don't wnat to use to control the the selection of Context of sub-job. What I want is after I export the parent job, I can run the parent job in command-line in different environments (DEV, UAT, PROD) just by specifying different parameter "--context=XXX" without changing the application and re-exporting the job. The issue is that the command-line parameter "--context=XXX" only takes effect for the parent job, not the sub-job. How to make the command-line parameter "--context=XXX" take effect for both the parent job and the sub-job?
Community Manager

Re: How to set the context for sub-jobs through command-line?

Hello
The issue is that the command-line parameter "--context=XXX" only takes effect for the parent job, not the sub-job. How to make the command-line parameter "--context=XXX" take effect for both the parent job and the sub-job?

You need to check the box 'Transmit whole context'.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business