Search code examples
shellunixetltalend

Passing context variable from unix shell to Parent Job and then passing it between job


I have a requirement. I am trying to pass a context variable defined in Talend(name=nomeFile, value=context.nome_file) from unix to myParent Job and then I want to pass it between my jobs. In this case the variable must be read from mainALF and passed to subLoad_Alf. I developed both ParentJob and ChildJob and after that I build myParentJob. At this point from unix terminal I wrote the following command:

./myParentJob.sh --context_param nomeFile="myDirectory/FileName.txt" and I does not work. I got "No such file or directory".

This is my main Job (myParentJob):

enter image description here

On the contrary, If I build myChildJob(subLoad_Alf) and I run the same command: ./myChildJob.sh --context_param nomeFile="myDirectory/FileName.txt" it works.

I think I am not able to read the context variable (nomeFile) in the ParentJob and send its value ("myDirectory/FileName.txt") to myChildJob. This is my childJob config:

enter image description here enter image description here

Does anyone can help me to figure out how to achieve this requirement?


Solution

  • The problem is that you are overriding your nomeFile context variable when you pass it to the child job.
    The global variable (globalMap.get("context.nomeFile")) that you are using to override the context variable does not exist, hence the empty context.nomeFile that is passed to your child job.
    Checking "Transmit whole context" on the child job's tRunJob will take care of passing the nomeFile that was passed to your parent job. You don't need to explicitly specify a value for that context variable so you need to remove it from context params table.