> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Learn how to use and configure environment variables in Gitpod workspaces.

Environment variables in Gitpod help you store sensitive information and configure your workspaces. They can be set at different levels, including [user-specific](/classic/user/configure/user-settings/environment-variables) and [repository-specific](/classic/user/configure/repositories/environment-variables) settings. See the [Prioritization Stack chart](#workspace-environment-variable-prioritization-stack) below for all the different sources of environmental variables in a workspace.

## Environment Variable Priority

Environment variables can come from multiple sources. Below is the order of precedence (ordered from lowest to highest priority) for environment variables in a Gitpod workspace:

```mermaid theme={null}
flowchart TD
    A["Image's environment variables<br/>(e.g., ENV in Dockerfile)"] --> B[".gitpod.yml[env]"]
    B --> C["User-specific environment<br/>variables"]
    C --> D["Repository-specific<br/>environment variables"]
    D --> E["Environment variables via<br/>context URL"]
    E --> F[".gitpod.yml[tasks][n][env]"]
```

### Image environment variables

* Set in the Dockerfile using ENV instructions or provided by the underlying image
* Provides base environment configuration
* [Documentation →](/classic/user/configure/workspaces/workspace-image)

### Global environment variables (`.gitpod.yml[env]`)

* Set workspace-wide variables in your `.gitpod.yml`
* Apply to all tasks in the workspace
* [Documentation →](/classic/user/references/gitpod-yml#env)

### User-specific environment variables

* Set in user settings
* Apply across all workspaces
* [Documentation →](/classic/user/configure/user-settings/environment-variables)

### Repository-specific environment variables

* Set in the repository settings in the Dashboard
* [Documentation →](/classic/user/configure/repositories/environment-variables#repository-specific-environment-variables)

### One-time environment variables (via context URL)

* Pass temporary variables through the Gitpod URL
* Format: `https://gitpod.io/#var=value,var2=value2/[repository-url]`
* Values are URL encoded
* Not suitable for sensitive information
* Example: [template-selective-services](https://github.com/gitpod-io/template-selective-services)

<Warning>
  When using context URL environment variables, avoid passing sensitive information like passwords or API tokens. Both Gitpod and the [Open Web Application Security Project](https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url) recommend against passing sensitive information through query strings. See [CWE-598](https://cwe.mitre.org/data/definitions/598.html) for more information.
</Warning>

### Task-specific environment variables (`.gitpod.yml[tasks][n][env]`)

* Set per-task environment variables in your `.gitpod.yml`
* Useful for task-specific configurations
* [Documentation →](/classic/user/references/gitpod-yml#tasksnenv)

## Exporting your Gitpod environment variables

You can export all your configured environment variables from your Gitpod workspace to a file. This includes both [user-specific](/classic/user/configure/user-settings/environment-variables) and [repository-specific](/classic/user/configure/repositories/environment-variables) environment variables.

```bash theme={null}
gp env > gitpod.env
```

This will save all your environment variables to a file named `gitpod.env`.

## Special Environment Variables

### Default Environment Variables

Gitpod automatically sets these core environment variables in every workspace:

* `GITPOD_WORKSPACE_ID`: A Universally Unique Identifier (UUID) for your workspace
* `GITPOD_WORKSPACE_URL`: The unique URL of your workspace
* `GITPOD_REPO_ROOT`: The path to your cloned git repository in the workspace

<Tip>
  Run `env | grep GITPOD_` in your workspace terminal to see all Gitpod-specific environment variables. These are helpful for creating dynamic workspace behaviors.
</Tip>

### Reserved Prefix

Gitpod reserves the `GITPOD_` prefix for internal use. Any user-defined variables with this prefix (like `GITPOD_FOOBAR`) will be ignored and overwritten during workspace startup.

### Git Configuration

By default, your name and email address for git commits are set using your connected SCM integration. If you want to override these settings, you can use the following environment variables:

* `GIT_AUTHOR_NAME`
* `GIT_AUTHOR_EMAIL`
* `GIT_COMMITTER_NAME`
* `GIT_COMMITTER_EMAIL`

### `DOCKERD_ARGS`

The `DOCKERD_ARGS` environment variable can be used to specify additional arguments to the docker installation running in your workspace. Currently,
mapping a user in your container to the `gitpod` user in your workspace is supported. This helps if you are using an unprivileged user with your containers
(e.g., user 1000 in a node image) but need to edit files with VS Code created within the container. The content of the environment variable
should look like this:

```json theme={null}
{ "remap-user": "1000" }
```

### `GITPOD_IMAGE_AUTH`

You can use the `GITPOD_IMAGE_AUTH` environment variable to authenticate against private container registries. See the [Workspace Image docs](/classic/user/configure/workspaces/workspace-image#use-a-private-docker-image) for more information.
