When you call forge create
, we automatically create three environments for you:
Environments are where you deploy your app. Once an app is running in an environment,
you can install it from that environment on to an Atlassian site with forge install
.
This process is documented in our
app tutorials.
We recommend using the development environment for testing your changes, staging for a stable version of your app, and production as the version of your app that’s ready for use.
By default, the CLI will run commands for the development environment unless you specify
another with the --environment
flag.
While your app is deployed to development, your app title will have the suffix (DEVELOPMENT)
.
Similarly, while your app is deployed to staging, it will have the suffix (STAGING)
.
Once you deploy your app to production, your app title will no longer have any suffix.
When using the staging environment, you can't use the forge tunnel
command. You'll need
to redeploy your app using forge deploy
each time you make a code change.
When using the staging and development environments, you won't be able to view the scopes defined for the APIs included in your Forge app. You'll need to deploy your app to the production environment for scopes to display. See View Forge app permissions for more details.
When using the production environment, you can't use the forge tunnel
or forge logs
commands.
To debug issues, you’ll need to redeploy your affected
code to the staging or development environments where you have access to
debugging tools.
For apps installed on sites you don’t have access to, you’ll need to ask the app
user to
download the logs for your app and send them to you.
Environment variables are key-value pairs you can manage via the Forge CLI variables commands. Each of your variables has separate values corresponding to the different environments your app is deployed to (development, staging, production). As with other Forge CLI commands, the Forge CLI variables commands act on the development environment unless another environment is specified explicitly.
You cannot access environment variables in the snapshot context.
List your environment variables by running:
1 2forge variables list
Set a variable with key MY_KEY and value my-value by running:
1 2forge variables set MY_KEY my-value
Set an encrypted variable by providing the --encrypt
option by running:
1 2forge variables set --encrypt MY_KEY my-value
Encrypted values are protected from forge variables list
output. However, they are
passed to your app's environment as clear text.
Unset a variable with key MY_KEY by running:
1 2forge variables unset MY_KEY
Read a variable with key MY_KEY in your code as below:
1 2process.env.MY_KEY
The same variable can be set in the production environment through the --environment
option.
1 2forge variables set --environment production --encrypt MY_KEY my-value
When you're using the forge tunnel
command, you must prefix environment variables with
FORGE_USER_VAR_
.
Set the value of MY_KEY
by prefixing FORGE_USER_VAR_
to the variable name, then
running the following command in your terminal:
1 2export FORGE_USER_VAR_MY_KEY=test
You do not need to change variable assignment when using environment variables with forge tunnel
,
the variable is still accessed with MY_KEY
.
1 2const myVar = process.env.MY_KEY // MY_KEY will be "test"
When you run the forge deploy
command for the first time without specifying an environment, you are prompted
to set your default development environment. Setting a default environment lets you work on an app without
impacting the work of other contributors.
When setting the name of your default development environment, make sure not to use any
sensitive information. You can change your default environment and its name at any time
using forge settings
.
By default, the CLI will run commands for your default development environment unless you specify
another with the --environment
flag.
You can create and manage additional development environments with forge environments
. Additional development environments allow multiple contributors to tunnel and deploy to their own development environment simultaneously.
To create a new development environment:
Run the following command in your CLI:
1 2forge environments create
Enter a name for your environment.
1 2Create a new development environment. ? Enter a name for your environment: my-dev-environment Creating environment... Created DEV my-dev-environment You can now tunnel or deploy to this new development environment.
When you run forge deploy, a new version is created in the Forge environment you specified (or in your default environment). See App versions for more information.
Rate this page: