Create an Environment Variable

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: Create an environment variable for use at either global or project level.

Security: Requires a valid user

Usage: POST api/v1/environmentVariables

Consumes: application/json

URL Parameters: None

Query String Parameters: Ignored

Request Parameters:

Parameter

Type

Description

Required/Optional

key

String

Environment variable key.

Required

value

String

Environment variable value.

Required

scope

String

Scope of the environment variable. It can be either 'global' or 'project'.

Default value is global.

Optional

projectId

Integer

Id of the Project.

Required if scope is set as 'project'.

isReadOnly

Boolean

Sets the precedence for the environment variable.

When set as true, this cannot be overridden by other environment variables. For example, if the scope is set asglobalandisReadOnlyis set astrue, other environment variables set at Project, pipeline, and step level cannot override the global environment variable.

Default value is false.

Optional

Produces: application/json

Sample Request:

curl -L -X POST 'https://icarus.jfrogdev.org/pipelines/api/v1/environmentVariables' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
--data-raw '{
        key: hello,
        value: world,
        scope: global,
        projectId: 2 
        isReadOnly: true
}

Sample Response:

{
        Id: 4,
        key: hello,
        value: world,
        scope: global,
        projectId: 2 
        isReadOnly: true 
}

Response Codes:

200: Success