Passing a context file from command line

Five Stars

Passing a context file from command line

Hello everyone,

 

I found a lot of threads about this problem but none helps me.

 

I try to execute a job from the command line by passing the following command (I need to execute job with two different contexts):

myJob.bat --context=myContext

 

The problem is such as myContext needs to be in a specific folder of the job folder. However, I need my context in an other place. So I should pass the path of the context file in the context parameter like:

myJob.bat --context=path/myContext

But it seems to not work, I got an error message 'Could not find the context myContext'.

I tried with simple cotes and doubles cotes but it didn't change anything.

 

How to pass this kind of parameter, a context file with a specific path?

Or, how to change the default folder where the context files need to be there?

 

Here is the tree view to help understanding the need:

  • jobFolder
    • myJob (the .bat file)
    • project (folder generated by Talend when building the job)
      • job
        • contexts
          • Context files that I can pass (so I should copy my context files there but I need them in an other folder)
  • customizedContexts
    • myContext (the context file that I want to pass, but I don't know how to pass the path to this file)

 

Thank you for your help,

 

Kevin

Employee Ram
Employee

Re: Passing a context file from command line

I believe passing passing --context=myContext might only pass the name of the context env ex. Dev, Prod, ... but cannot externalize the location of a context file.

try using a tFileInputDelimited-> tContextLoad to externalize the context file. See the doc of tContextLoad
Five Stars

Re: Passing a context file from command line

I created two tFileInputDelimited-> tContextLoad units in my job, that correspond to my two contexts.

 

How to pass the context that I want to use when I execute the job from the command line? I seen something like --context_parameter but it didn't works for me.

 

Or do I need to have only one tFileInputDelimited-> tContextLoad unit, and a .properties file that contains my two environments? In this case, how to choose which one environment I want to use when I pass the context form the command line?

 

Thanks,

Kevin

Employee Ram
Employee

Re: Passing a context file from command line

Here is the command line help. You can pass the context name using --job-context

 

executeJob jobName executes |
| -i (--interpreter) path perl/java interpreter path |
| -jactc (--job-apply-context-to-children) apply context to children |
| -jc (--job-context) context name chooses a job context |
| -jcp (--job-context-param) key=value [key=value ...] provides a job context param |
| -jrdd (--job-result-destination-dir) path job execution result |
| destination dir |
| -jt (--job-timeout) time (in sec) timeout of execution |
| -jv (--job-version) version chooses a job version |

 


| executeJobOnServer jobName executes on server |
| -es (--execution-server) name execution [virtual] server |
| name |
| -jactc (--job-apply-context-to-children) apply context to children |
| -jall (--job-log4j-level) level log4j level |
| -jc (--job-context) context name chooses a job context |
| -jcp (--job-context-param) key=value [key=value ...] provides a job context param |
| -jrrd (--job-result-destination-dir) jobResultDestDir job execution result |
| destination dir |
| -jsp (--job-statistics-port) port setup the statistics port |
| -jtp (--job-trace-port) port setup the trace port |
| -jv (--job-version) version chooses a job version |
| -pd (--jobserver-password) password jobserver password |
| -ra (--run-as-user) runas run as user |
| -un (--jobserver-username) username jobserver username |
| -useSSL (--use-ssl-option) use ssl Protocol or not

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download