一、要使用kettle.properties变量,需要加入Kettle环境变量
Windows:

变量名:KETTLE_HOME,变量值:C:\pdi-ce-8.3.0.0-371\data-integration(kettle主目录),重启Kettle即可。

Linux:

vi /etc/profile
export KETTLE_HOME=/usr/local/kettle#kettle主目录
source /etc/profile

二、在kettle主目录新建.kettle文件夹(保证跟 spoon.bat 同一目录),然后新建kettle.properties文件,变量采用key-value的方式,如下:

# This file was generated by Pentaho Data Integration version 6.1.0.1-196.
# 
# Here are a few examples of variables to set: 
#
# PRODUCTION_SERVER = hercules
# TEST_SERVER = zeus
# DEVELOPMENT_SERVER = thor
#
# Note: lines like these with a # in front of it are comments
#
#######db_localhost#########
CONN_IP_local_F = 127.0.0.1
CONN_NAME_local_F = test
CONN_PROT_local_F = 3306
CONN_USERNAME_local_F = root
CONN_USERPASS_local_F = root

三、在需要的地方使用变量即可,例如下面的数据连接方式
带参数的数据库连接

注意:SQL语句需要把替换SQL语句里的变量勾选。