Kettle新手求助:无法向Pentaho KJB文件传递filePath参数
Hey there! Since you’ve got the filePath parameter working perfectly in Spoon, let’s get it sorted for other execution methods—here’s how to pass that parameter reliably no matter how you run your KJB:
This is the most common way to run Kettle jobs outside the GUI. You’ll use the kitchen.sh (Linux/macOS) or kitchen.bat (Windows) tool, and pass the parameter directly with the -param: flag.
Example Commands:
- Windows:
Kitchen.bat /file:"C:\path\to\your\job.kjb" /param:filePath="C:\data\your_input_file.csv" - Linux/macOS:
./kitchen.sh -file="/home/you/path/to/job.kjb" -param:filePath="/home/you/data/your_input_file.csv"
Notes:
- Wrap paths with spaces in double quotes to avoid parsing errors.
- Run the command from the
data-integrationdirectory of your Kettle installation, or use absolute paths for bothkitchenand your KJB file.
If you’re using Carte to run jobs on a remote server, you can pass parameters either through the web UI or via an API call:
Web UI Method:
- Log into your Carte server’s web interface (typically
http://your-server:8080/kettle). - Navigate to Jobs > Execute a Job.
- Enter the path to your KJB, then scroll to the Parameters section.
- Add a new parameter with key
filePathand your desired file path as the value, then submit the job.
API/Curl Method:
Use a POST request to submit the job with parameters:
curl -X POST "http://your-carte-server:8080/kettle/executeJob" \ -d "job=/path/to/your/job.kjb¶m:filePath=/full/path/to/input/file.csv"
When scheduling your job, you just need to embed the parameter in the command you schedule:
Linux Cron Example:
Add this line to your crontab (run crontab -e to edit) to run the job daily at 2 AM:
0 2 * * * /opt/pentaho/data-integration/kitchen.sh -file="/opt/jobs/your_job.kjb" -param:filePath="/opt/data/daily_input.csv"
Windows Task Scheduler Example:
- Create a new task, set the trigger time.
- For the action, select Start a program, then browse to
Kitchen.bat(usually inC:\Pentaho\data-integration\Kitchen.bat). - In the Add arguments field, enter:
/file:"C:\jobs\your_job.kjb" /param:filePath="C:\data\daily_input.csv"
- Case Sensitivity: Kettle parameter names are case-sensitive—make sure you’re using exactly
filePath(notfilepathorFilePath) when passing the parameter. - Variable Mapping: Double-check your KJB’s "Set Variables" step: ensure it’s set to pull the value from the
filePathparameter, and that the variable name matches what your KTR is expecting. - Log Checks: Add
-level=Detailedto your command line to get verbose logs—this will show if the parameter is being picked up correctly by the job. - Path Formatting: On Windows, use backslashes in paths (no need to escape them if wrapped in quotes); on Linux/macOS, use forward slashes.
内容的提问来源于stack exchange,提问作者KCK

