# KETTLE Variables

{% hint style="warning" %}

#### **Workshop - Kettle Variables**

Use variables to avoid hardcoded paths and values.

Use `kettle.properties` to store global variables for Spoon.

In this workshop, you will create a global variable. You will then use it in a transformation.

**What You'll Accomplish:**

* Access and edit the kettle.properties configuration file
* Define a global variable for jobs and transformations
* Use both variable formats (`${VAR}` and `%%VAR%%`)
* Insert variables with `Ctrl+Space`

**Prerequisites:** Pentaho Data Integration installed and configured

**Estimated Time:** 10 minutes
{% endhint %}

***

{% hint style="info" %}

#### **Global Variables - kettle.properties**

Variables can be used throughout Pentaho Data Integration, including in transformation steps and job entries. You define variables by setting them with the Set Variable step in a transformation or by setting them in the kettle.properties file in the directory.

Use variables by either retrieving them with the Get Variable step or by using metadata strings like:

* `${VARIABLE}`
* `%%VARIABLE%%`

You can mix both formats. The first is Unix-style. The second is Windows-style.

Fields that support variables show the blue `${}` icon.

Press `Ctrl+Space` to insert a variable in those fields. Hover over the icon to see help.
{% endhint %}

{% embed url="<https://www.loom.com/share/89d5419da317432eb272b583e30f8904?hideEmbedTopBar=true&hide_owner=true&hide_share=true&hide_title=true>" %}
KETTLE Variables
{% endembed %}

{% file src="/files/o77ZkN95sy2DlfKXYFwh" %}

***

1. Start Pentaho Data Integration.

{% hint style="info" %}
{% tabs %}
{% tab title="Windows (PowerShell)" %}

```powershell
Set-Location C:\Pentaho\design-tools\data-integration
.\spoon.bat
```

{% endtab %}

{% tab title="macOS / Linux" %}

```bash
cd ~/Pentaho/design-tools/data-integration
./spoon.sh
```

{% endtab %}
{% endtabs %}
{% endhint %}

2. Select Edit -> Edit the kettle.properties file
3. Highlight the first row and right mouse click, and select the following option.

<figure><img src="/files/RVMx57NJQ5JiGf1GCYsP" alt=""><figcaption><p>Global variables</p></figcaption></figure>

4. Add a `DIR_SAMPLES` variable for your OS.

{% tabs %}
{% tab title="Windows" %}
Add this line:

```properties
DIR_SAMPLES=C:/Temp
```

{% endtab %}

{% tab title="Linux/macOS" %}
Add this line:

```properties
DIR_SAMPLES=/home/pentaho/Temp
```

{% endtab %}
{% endtabs %}

5. Save.

{% hint style="info" %}
Spoon loads `kettle.properties` on startup.

If variables do not show up, restart Spoon.
{% endhint %}

{% hint style="info" %}
You can also edit `kettle.properties` manually.

Default locations:

* Windows: `C:\Users\<username>\.kettle\kettle.properties`
* Linux/macOS: `~/.kettle/kettle.properties`

The PowerShell script uses [nano](https://github.com/okibcn/nano-for-windows) which was installed using [scoop](https://scoop.sh/)
{% endhint %}

6. Open a terminal.

{% tabs %}
{% tab title="Windows (PowerShell)" %}

```powershell
cd \
cd Workshop--Data-Integration\Scripts
.\edit-kettle.properties.ps1
```

{% endtab %}

{% tab title="Linux/macOS" %}

```bash
cd
cd ~/.kettle
nano kettle.properties
```

{% endtab %}
{% endtabs %}

<figure><img src="/files/FdiiVoSk4yNfvs9CeDqM" alt="" width="563"><figcaption><p>kettle.properties - Linux</p></figcaption></figure>

{% hint style="info" %}
Verify in Spoon:

1. Open any step property that shows the blue `${}` icon.
2. Press `Ctrl+Space`.
3. Search for `DIR_SAMPLES`.
4. Insert it into the field.
   {% endhint %}

<div align="center"><figure><img src="/files/rIBYtJr1YPxKnoFnbHYu" alt="" width="375"><figcaption><p>Global variable in Transformation</p></figcaption></figure></div>

{% embed url="<https://docs.pentaho.com/pdia-data-integration/data-integration-perspective-in-the-pdi-client/advanced-topics-pdi-perspective/pdi-run-modifiers/variables/kettle-variables>" %}

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://academy.pentaho.com/pentaho-data-integration/data-integration/components/kettle-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
