Skip to content

Commit 207c75b

Browse files
docs: document WRANGLER_OUTPUT_FILE_PATH and WRANGLER_OUTPUT_FILE_DIRECTORY environment variables
Add documentation for the WRANGLER_OUTPUT_FILE_PATH and WRANGLER_OUTPUT_FILE_DIRECTORY environment variables that allow capturing Wrangler command output in ND-JSON format. Documentation added to: - System environment variables reference page - wrangler deploy command - wrangler versions upload and deploy commands - wrangler pages deploy command These environment variables are useful for CI/CD pipelines and automation tools that need programmatic access to deployment information. Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
1 parent 3765d47 commit 207c75b

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/content/docs/workers/wrangler/commands.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ None of the options for this command are required. Also, many can be set in your
328328

329329
<Render file="wrangler-commands/global-flags" product="workers" />
330330

331+
### Capturing deployment output
332+
333+
When you deploy a Worker, you can capture deployment information in a structured format by setting the [`WRANGLER_OUTPUT_FILE_PATH`](/workers/wrangler/system-environment-variables/#supported-environment-variables) or [`WRANGLER_OUTPUT_FILE_DIRECTORY`](/workers/wrangler/system-environment-variables/#supported-environment-variables) environment variables. This writes deployment metadata (including worker name, version ID, and deployment URLs) to a file in [ND-JSON](https://github.com/ndjson/ndjson-spec) format, which is useful for CI/CD pipelines and automation tools.
334+
331335
---
332336

333337
## `delete`
@@ -1097,6 +1101,10 @@ Your site is deployed to `<PROJECT_NAME>.pages.dev`. If you do not provide the `
10971101

10981102
:::
10991103

1104+
#### Capturing deployment output
1105+
1106+
When you deploy a Pages project, you can capture deployment information in a structured format by setting the [`WRANGLER_OUTPUT_FILE_PATH`](/workers/wrangler/system-environment-variables/#supported-environment-variables) or [`WRANGLER_OUTPUT_FILE_DIRECTORY`](/workers/wrangler/system-environment-variables/#supported-environment-variables) environment variables. This writes deployment metadata (including project name, deployment ID, and deployment URL) to a file in [ND-JSON](https://github.com/ndjson/ndjson-spec) format, which is useful for CI/CD pipelines and automation tools.
1107+
11001108
### `secret put`
11011109

11021110
Create or update a secret for a Pages project.
@@ -1323,6 +1331,10 @@ description="Retrieve details for the 10 most recent versions. Details include `
13231331

13241332
/>
13251333

1334+
### Capturing version output
1335+
1336+
When you upload or deploy a version, you can capture version information in a structured format by setting the [`WRANGLER_OUTPUT_FILE_PATH`](/workers/wrangler/system-environment-variables/#supported-environment-variables) or [`WRANGLER_OUTPUT_FILE_DIRECTORY`](/workers/wrangler/system-environment-variables/#supported-environment-variables) environment variables. This writes version metadata (including worker name, version ID, and preview URLs for uploads, or deployment information for deploys) to a file in [ND-JSON](https://github.com/ndjson/ndjson-spec) format, which is useful for CI/CD pipelines and automation tools.
1337+
13261338
### `secret put`
13271339

13281340
Create or replace a secret for a Worker. Creates a new [version](/workers/configuration/versions-and-deployments/#versions) with modified secrets without [deploying](/workers/configuration/versions-and-deployments/#deployments) the Worker.

src/content/docs/workers/wrangler/system-environment-variables.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ Wrangler supports the following environment variables:
8686

8787
* `WRANGLER_R2_SQL_AUTH_TOKEN` <Type text="string" /> <MetaInfo text="optional" />
8888
- API token used for executing queries with [R2 SQL](/r2-sql).
89+
90+
- `WRANGLER_OUTPUT_FILE_PATH` <Type text="string" /> <MetaInfo text="optional" />
91+
92+
- Specifies a file path where Wrangler will write output data in [ND-JSON](https://github.com/ndjson/ndjson-spec) (newline-delimited JSON) format. Each line in the file is a separate JSON object containing information about Wrangler operations such as deployments, version uploads, and errors. This is useful for CI/CD pipelines and automation tools that need to programmatically access deployment information. If both `WRANGLER_OUTPUT_FILE_PATH` and `WRANGLER_OUTPUT_FILE_DIRECTORY` are set, `WRANGLER_OUTPUT_FILE_PATH` takes precedence.
93+
94+
- `WRANGLER_OUTPUT_FILE_DIRECTORY` <Type text="string" /> <MetaInfo text="optional" />
95+
96+
- Specifies a directory where Wrangler will create a randomly-named file (format: `wrangler-output-<timestamp>-<random>.json`) to write output data in [ND-JSON](https://github.com/ndjson/ndjson-spec) format. This is useful when you want to keep output files organized in a specific directory but don't need to control the exact filename. If both `WRANGLER_OUTPUT_FILE_PATH` and `WRANGLER_OUTPUT_FILE_DIRECTORY` are set, `WRANGLER_OUTPUT_FILE_PATH` takes precedence.
97+
8998
## Example `.env` file
9099

91100
The following is an example `.env` file:

0 commit comments

Comments
 (0)