# buildkite-agent meta-data

The Buildkite agent's `meta-data` command provides your build pipeline with a powerful key/value data-store that works across build steps and build agents, no matter the machine or network.

See the [Using build meta-data](/docs/pipelines/configure/build-meta-data) guide for a step-by-step example.

## Setting data

Use this command in your build scripts to save string data in the Buildkite meta-data store.

### Usage

`buildkite-agent meta-data set <key> [value] [options...]`

### Description

Set arbitrary data on a build using a basic key/value store.

You can supply the value as an argument to the command, or pipe in a file or
script output.

The value must be a non-empty string, and strings containing only whitespace
characters are not allowed.

### Example

```shell
$ buildkite-agent meta-data set "foo" "bar"
$ buildkite-agent meta-data set "foo" < ./tmp/meta-data-value
$ ./script/meta-data-generator | buildkite-agent meta-data set "foo"
```

### Options



| `--no-color ` # | Don't show colors in logging (default: false) **Environment variable**: `$BUILDKITE_AGENT_NO_COLOR` |
| --- | --- |
| `--debug ` # | Enable debug mode. Synonym for `--log-level debug`. Takes precedence over `--log-level` (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG` |
| `--log-level string` # | Set the log level for the agent, making logging more or less verbose. Defaults to notice. Allowed values are: debug, info, error, warn, fatal (default: "notice") **Environment variable**: `$BUILDKITE_AGENT_LOG_LEVEL` |
| `--experiment string` # | Enable experimental features within the buildkite-agent **Environment variable**: `$BUILDKITE_AGENT_EXPERIMENT` |
| `--profile string` # | Enable a profiling mode, either cpu, memory, mutex or block **Environment variable**: `$BUILDKITE_AGENT_PROFILE` |
| `--agent-access-token string` # | The access token used to identify the agent **Environment variable**: `$BUILDKITE_AGENT_ACCESS_TOKEN` |
| `--endpoint string` # | The Agent API endpoint (default: "https://agent-edge.buildkite.com/v3") **Environment variable**: `$BUILDKITE_AGENT_ENDPOINT` |
| `--no-http2 ` # | Disable HTTP2 when communicating with the Agent API (default: false) **Environment variable**: `$BUILDKITE_NO_HTTP2` |
| `--debug-http ` # | Enable HTTP debug mode, which dumps all request and response bodies to the log (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG_HTTP` |
| `--trace-http ` # | Enable HTTP trace mode, which logs timings for each HTTP request. Timings are logged at the debug level unless a request fails at the network level in which case they are logged at the error level (default: false) **Environment variable**: `$BUILDKITE_AGENT_TRACE_HTTP` |
| `--job string` # | Which job's build should the meta-data be set on **Environment variable**: `$BUILDKITE_JOB_ID` |
| `--redacted-vars string` # | Pattern of environment variable names containing sensitive values (default: "*_PASSWORD", "*_SECRET", "*_TOKEN", "*_PRIVATE_KEY", "*_SSH_KEY", "*_ACCESS_KEY", "*_SECRET_KEY", "*_CONNECTION_STRING", "*_API_KEY") **Environment variable**: `$BUILDKITE_REDACTED_VARS` |



## Setting multiple values

Use this command in your build scripts to save multiple key/value pairs in the Buildkite meta-data store.

### Usage

`buildkite-agent meta-data set-batch <key=value>... [options...]`

### Description

Set multiple meta-data key/value pairs on a build in a single request.

Each argument must be in key=value format.

Keys and values must be non-empty strings, and strings containing only
whitespace characters are not allowed.

### Example

```shell
$ buildkite-agent meta-data set-batch foo=bar "greeting=hello world"
$ buildkite-agent meta-data set-batch duration:spec/a.rb=2.341 duration:spec/b.rb=5.672
```

### Options



| `--no-color ` # | Don't show colors in logging (default: false) **Environment variable**: `$BUILDKITE_AGENT_NO_COLOR` |
| --- | --- |
| `--debug ` # | Enable debug mode. Synonym for `--log-level debug`. Takes precedence over `--log-level` (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG` |
| `--log-level string` # | Set the log level for the agent, making logging more or less verbose. Defaults to notice. Allowed values are: debug, info, error, warn, fatal (default: "notice") **Environment variable**: `$BUILDKITE_AGENT_LOG_LEVEL` |
| `--experiment string` # | Enable experimental features within the buildkite-agent **Environment variable**: `$BUILDKITE_AGENT_EXPERIMENT` |
| `--profile string` # | Enable a profiling mode, either cpu, memory, mutex or block **Environment variable**: `$BUILDKITE_AGENT_PROFILE` |
| `--agent-access-token string` # | The access token used to identify the agent **Environment variable**: `$BUILDKITE_AGENT_ACCESS_TOKEN` |
| `--endpoint string` # | The Agent API endpoint (default: "https://agent-edge.buildkite.com/v3") **Environment variable**: `$BUILDKITE_AGENT_ENDPOINT` |
| `--no-http2 ` # | Disable HTTP2 when communicating with the Agent API (default: false) **Environment variable**: `$BUILDKITE_NO_HTTP2` |
| `--debug-http ` # | Enable HTTP debug mode, which dumps all request and response bodies to the log (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG_HTTP` |
| `--trace-http ` # | Enable HTTP trace mode, which logs timings for each HTTP request. Timings are logged at the debug level unless a request fails at the network level in which case they are logged at the error level (default: false) **Environment variable**: `$BUILDKITE_AGENT_TRACE_HTTP` |
| `--job string` # | Which job's build should the meta-data be set on **Environment variable**: `$BUILDKITE_JOB_ID` |
| `--redacted-vars string` # | Pattern of environment variable names containing sensitive values (default: "*_PASSWORD", "*_SECRET", "*_TOKEN", "*_PRIVATE_KEY", "*_SSH_KEY", "*_ACCESS_KEY", "*_SECRET_KEY", "*_CONNECTION_STRING", "*_API_KEY") **Environment variable**: `$BUILDKITE_REDACTED_VARS` |



Meta-data values are restricted to a maximum of 100 kilobytes. Keys and values larger than 1 kilobyte are discouraged. Please use [artifacts](/docs/agent/cli/reference/artifact) for large data that needs to be uploaded and downloaded.

## Getting data

Use this command in your build scripts to get a previously saved value from the Buildkite meta-data store.

### Usage

`buildkite-agent meta-data get <key> [options...]`

### Description

Get data from a build&#39;s key/value store.

### Example

```shell
$ buildkite-agent meta-data get "foo"
```

### Options



| `--no-color ` # | Don't show colors in logging (default: false) **Environment variable**: `$BUILDKITE_AGENT_NO_COLOR` |
| --- | --- |
| `--debug ` # | Enable debug mode. Synonym for `--log-level debug`. Takes precedence over `--log-level` (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG` |
| `--log-level string` # | Set the log level for the agent, making logging more or less verbose. Defaults to notice. Allowed values are: debug, info, error, warn, fatal (default: "notice") **Environment variable**: `$BUILDKITE_AGENT_LOG_LEVEL` |
| `--experiment string` # | Enable experimental features within the buildkite-agent **Environment variable**: `$BUILDKITE_AGENT_EXPERIMENT` |
| `--profile string` # | Enable a profiling mode, either cpu, memory, mutex or block **Environment variable**: `$BUILDKITE_AGENT_PROFILE` |
| `--agent-access-token string` # | The access token used to identify the agent **Environment variable**: `$BUILDKITE_AGENT_ACCESS_TOKEN` |
| `--endpoint string` # | The Agent API endpoint (default: "https://agent-edge.buildkite.com/v3") **Environment variable**: `$BUILDKITE_AGENT_ENDPOINT` |
| `--no-http2 ` # | Disable HTTP2 when communicating with the Agent API (default: false) **Environment variable**: `$BUILDKITE_NO_HTTP2` |
| `--debug-http ` # | Enable HTTP debug mode, which dumps all request and response bodies to the log (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG_HTTP` |
| `--trace-http ` # | Enable HTTP trace mode, which logs timings for each HTTP request. Timings are logged at the debug level unless a request fails at the network level in which case they are logged at the error level (default: false) **Environment variable**: `$BUILDKITE_AGENT_TRACE_HTTP` |
| `--default string` # | If the meta-data value doesn't exist return this instead |
| `--job string` # | Which job's build should the meta-data be retrieved from **Environment variable**: `$BUILDKITE_JOB_ID` |
| `--build string` # | Which build should the meta-data be retrieved from. --build will take precedence over --job **Environment variable**: `$BUILDKITE_METADATA_BUILD_ID` |



## Checking if data exists

### Usage

`buildkite-agent meta-data exists <key> [options...]`

### Description

The command exits with a status of 0 if the key has been set, or it will
exit with a status of 100 if the key doesn&#39;t exist.

### Example

```shell
$ buildkite-agent meta-data exists "foo"
```

### Options



| `--no-color ` # | Don't show colors in logging (default: false) **Environment variable**: `$BUILDKITE_AGENT_NO_COLOR` |
| --- | --- |
| `--debug ` # | Enable debug mode. Synonym for `--log-level debug`. Takes precedence over `--log-level` (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG` |
| `--log-level string` # | Set the log level for the agent, making logging more or less verbose. Defaults to notice. Allowed values are: debug, info, error, warn, fatal (default: "notice") **Environment variable**: `$BUILDKITE_AGENT_LOG_LEVEL` |
| `--experiment string` # | Enable experimental features within the buildkite-agent **Environment variable**: `$BUILDKITE_AGENT_EXPERIMENT` |
| `--profile string` # | Enable a profiling mode, either cpu, memory, mutex or block **Environment variable**: `$BUILDKITE_AGENT_PROFILE` |
| `--agent-access-token string` # | The access token used to identify the agent **Environment variable**: `$BUILDKITE_AGENT_ACCESS_TOKEN` |
| `--endpoint string` # | The Agent API endpoint (default: "https://agent-edge.buildkite.com/v3") **Environment variable**: `$BUILDKITE_AGENT_ENDPOINT` |
| `--no-http2 ` # | Disable HTTP2 when communicating with the Agent API (default: false) **Environment variable**: `$BUILDKITE_NO_HTTP2` |
| `--debug-http ` # | Enable HTTP debug mode, which dumps all request and response bodies to the log (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG_HTTP` |
| `--trace-http ` # | Enable HTTP trace mode, which logs timings for each HTTP request. Timings are logged at the debug level unless a request fails at the network level in which case they are logged at the error level (default: false) **Environment variable**: `$BUILDKITE_AGENT_TRACE_HTTP` |
| `--job string` # | Which job's build should the meta-data be checked for **Environment variable**: `$BUILDKITE_JOB_ID` |
| `--build string` # | Which build should the meta-data be retrieved from. --build will take precedence over --job **Environment variable**: `$BUILDKITE_METADATA_BUILD_ID` |



## Listing keys

### Usage

`buildkite-agent meta-data keys [options...]`

### Description

Lists all meta-data keys that have been previously set, delimited by a newline
and terminated with a trailing newline.

### Example

```shell
$ buildkite-agent meta-data keys
```

### Options



| `--no-color ` # | Don't show colors in logging (default: false) **Environment variable**: `$BUILDKITE_AGENT_NO_COLOR` |
| --- | --- |
| `--debug ` # | Enable debug mode. Synonym for `--log-level debug`. Takes precedence over `--log-level` (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG` |
| `--log-level string` # | Set the log level for the agent, making logging more or less verbose. Defaults to notice. Allowed values are: debug, info, error, warn, fatal (default: "notice") **Environment variable**: `$BUILDKITE_AGENT_LOG_LEVEL` |
| `--experiment string` # | Enable experimental features within the buildkite-agent **Environment variable**: `$BUILDKITE_AGENT_EXPERIMENT` |
| `--profile string` # | Enable a profiling mode, either cpu, memory, mutex or block **Environment variable**: `$BUILDKITE_AGENT_PROFILE` |
| `--agent-access-token string` # | The access token used to identify the agent **Environment variable**: `$BUILDKITE_AGENT_ACCESS_TOKEN` |
| `--endpoint string` # | The Agent API endpoint (default: "https://agent-edge.buildkite.com/v3") **Environment variable**: `$BUILDKITE_AGENT_ENDPOINT` |
| `--no-http2 ` # | Disable HTTP2 when communicating with the Agent API (default: false) **Environment variable**: `$BUILDKITE_NO_HTTP2` |
| `--debug-http ` # | Enable HTTP debug mode, which dumps all request and response bodies to the log (default: false) **Environment variable**: `$BUILDKITE_AGENT_DEBUG_HTTP` |
| `--trace-http ` # | Enable HTTP trace mode, which logs timings for each HTTP request. Timings are logged at the debug level unless a request fails at the network level in which case they are logged at the error level (default: false) **Environment variable**: `$BUILDKITE_AGENT_TRACE_HTTP` |
| `--job string` # | Which job's build should the meta-data be checked for **Environment variable**: `$BUILDKITE_JOB_ID` |
| `--build string` # | Which build should the meta-data be retrieved from. --build will take precedence over --job **Environment variable**: `$BUILDKITE_METADATA_BUILD_ID` |



