Environment's Deployment

An environment's offline deployment is used for deploying environments to a server not from Studio.

Deployment using deploy-environment.sh

Run deploy-environment.sh to deploy the environment configuration from a build server or CI/CD pipeline. The script is located under $FABRIC_HOME/fabric/scripts and supports both local and remote deployment:

  • Local deploy — connects to a running Fabric instance on the same machine via the Fabric CLI.
  • Remote deploy — uses the Fabric HTTP API (-r flag). Does not require a local Fabric installation.

Usage:

./deploy-environment.sh [options]

Options:

The options are passed as command-line arguments. They can also be set as environment variables before running the script, although passing them as arguments is the recommended approach.

Option

Environment Variable

Description

Default

-host / --host

HOST

Fabric host (IP address or URL).

localhost

-port / --port

PORT

Fabric port. See the note below the table.

5124

-u / --username

USERNAME

Fabric username.

admin

-p / --password

PASSWORD

Fabric password.

admin

-t / --token

TOKEN

Fabric API token, sent as a token URL parameter.

-b / --bearer

BEARER_TOKEN

Fabric API token, sent as an Authorization: Bearer header instead of a URL parameter. Available from Fabric 8.5.1.

-pd / --project-dir

PROJECT_DIR

Path to the project directory. Used to locate the default environment file.

-ef / --environment-file

ENVIRONMENT_FILE

Path to the environment XML file.

<project>/Implementation/SharedObjects/Environments/Environments.k2fabEnv.xml

-e / --environment

ENVIRONMENT

Environment name to set as active after deployment.

-r / --remote-deploy

REMOTE_DEPLOY

Enable remote deployment via HTTP API.

false

-h / --help

Displays usage information.

The port depends on the deploy mode. A local deploy connects to the Fabric JDBC endpoint, using the default port 5124. A remote deploy connects to the Fabric REST API endpoint, whose default port is 3213 — set it explicitly unless it is already part of the host URL.

Authentication: the script accepts -b / --bearer, -t / --token, or -u / --username with -p / --password. If more than one is set, --bearer is used first, then --token, then --username/--password.

In local mode, the script runs two operations: deploys the environment file, then sets the active environment (if -e is provided).

Example — deploy environment file and activate it on a remote server:

./deploy-environment.sh \
  -pd /opt/apps/MyProject \
  -host 10.0.0.5 \
  -b $API_TOKEN \
  -r \
  -e Production

Deployment using the Fabric Console

Perform the following actions:

  1. Connect to a server using the Fabric Console.

  2. Copy the Environments.k2fabEnv.XML file from the following Windows location - [Fabric Project’s Directory]\[Project Name]\Implementation\SharedObjects\Environments - or manually edit the existing XML file.

  3. Deploy the environments file using the following command:

   Deploy environments from file ‘{filename}’

where {filename} includes the file’s path and name on the server.

Fabric encrypts the passwords in the file (if they are not already encrypted) and saves the XML file with the encrypted passwords.

Note that deploying an XML file overrides all existing environments - except for _dev - which is the default environment. If the environment exists in Fabric, but not in the deployed XML file, it is removed from Fabric.

Deployment using API calls

Request URL Format

POST https://<FABRIC-IP>:<FABRIC-PORT>/deployEnvironment?[token=<APIKEY>][user=<USER-NAME>&password=<PASSWORD>][&environment=<ENVIRONMENT-TO-SET>]

Parameters

Parameter

Description

Mandatory

environment

When sent, the target Fabric server sets this environment to be active, similar to running "SET_GLOBAL ENVIRONMENT" command.

N

Authentication & Authorization

Authenticate with any one of the following.

Request header:

  • Authorization: Bearer <APIKEY> — available from Fabric 8.5.1.

URL parameters:

  • token=<APIKEY>
  • user=<USER-NAME>&password=<PASSWORD>

The request caller shall be authorized with the right permissions to perform the deploy (granted with "DEPLOY_ENVIRONMENTS" permission). See here for more information.

Request Body

Body parameters, along with the deployment files, to be sent with ContentType header = multipart/form-data.

Parameter

Description

Mandatory

file

Path to the Environments XML file

Y

Previous

Environment's Deployment

An environment's offline deployment is used for deploying environments to a server not from Studio.

Deployment using deploy-environment.sh

Run deploy-environment.sh to deploy the environment configuration from a build server or CI/CD pipeline. The script is located under $FABRIC_HOME/fabric/scripts and supports both local and remote deployment:

  • Local deploy — connects to a running Fabric instance on the same machine via the Fabric CLI.
  • Remote deploy — uses the Fabric HTTP API (-r flag). Does not require a local Fabric installation.

Usage:

./deploy-environment.sh [options]

Options:

The options are passed as command-line arguments. They can also be set as environment variables before running the script, although passing them as arguments is the recommended approach.

Option

Environment Variable

Description

Default

-host / --host

HOST

Fabric host (IP address or URL).

localhost

-port / --port

PORT

Fabric port. See the note below the table.

5124

-u / --username

USERNAME

Fabric username.

admin

-p / --password

PASSWORD

Fabric password.

admin

-t / --token

TOKEN

Fabric API token, sent as a token URL parameter.

-b / --bearer

BEARER_TOKEN

Fabric API token, sent as an Authorization: Bearer header instead of a URL parameter. Available from Fabric 8.5.1.

-pd / --project-dir

PROJECT_DIR

Path to the project directory. Used to locate the default environment file.

-ef / --environment-file

ENVIRONMENT_FILE

Path to the environment XML file.

<project>/Implementation/SharedObjects/Environments/Environments.k2fabEnv.xml

-e / --environment

ENVIRONMENT

Environment name to set as active after deployment.

-r / --remote-deploy

REMOTE_DEPLOY

Enable remote deployment via HTTP API.

false

-h / --help

Displays usage information.

The port depends on the deploy mode. A local deploy connects to the Fabric JDBC endpoint, using the default port 5124. A remote deploy connects to the Fabric REST API endpoint, whose default port is 3213 — set it explicitly unless it is already part of the host URL.

Authentication: the script accepts -b / --bearer, -t / --token, or -u / --username with -p / --password. If more than one is set, --bearer is used first, then --token, then --username/--password.

In local mode, the script runs two operations: deploys the environment file, then sets the active environment (if -e is provided).

Example — deploy environment file and activate it on a remote server:

./deploy-environment.sh \
  -pd /opt/apps/MyProject \
  -host 10.0.0.5 \
  -b $API_TOKEN \
  -r \
  -e Production

Deployment using the Fabric Console

Perform the following actions:

  1. Connect to a server using the Fabric Console.

  2. Copy the Environments.k2fabEnv.XML file from the following Windows location - [Fabric Project’s Directory]\[Project Name]\Implementation\SharedObjects\Environments - or manually edit the existing XML file.

  3. Deploy the environments file using the following command:

   Deploy environments from file ‘{filename}’

where {filename} includes the file’s path and name on the server.

Fabric encrypts the passwords in the file (if they are not already encrypted) and saves the XML file with the encrypted passwords.

Note that deploying an XML file overrides all existing environments - except for _dev - which is the default environment. If the environment exists in Fabric, but not in the deployed XML file, it is removed from Fabric.

Deployment using API calls

Request URL Format

POST https://<FABRIC-IP>:<FABRIC-PORT>/deployEnvironment?[token=<APIKEY>][user=<USER-NAME>&password=<PASSWORD>][&environment=<ENVIRONMENT-TO-SET>]

Parameters

Parameter

Description

Mandatory

environment

When sent, the target Fabric server sets this environment to be active, similar to running "SET_GLOBAL ENVIRONMENT" command.

N

Authentication & Authorization

Authenticate with any one of the following.

Request header:

  • Authorization: Bearer <APIKEY> — available from Fabric 8.5.1.

URL parameters:

  • token=<APIKEY>
  • user=<USER-NAME>&password=<PASSWORD>

The request caller shall be authorized with the right permissions to perform the deploy (granted with "DEPLOY_ENVIRONMENTS" permission). See here for more information.

Request Body

Body parameters, along with the deployment files, to be sent with ContentType header = multipart/form-data.

Parameter

Description

Mandatory

file

Path to the Environments XML file

Y

Previous