App Settings
As an app developer, you can add custom settings to your app. System or project administrators in YouTrack can provide values for app settings on the Settings tab of the app on global or project levels respectively.
You can use setting values in custom JavaScript scripts inside the app package, for example, in HTTP handlers, workflow rules, or other scripts. You can refer to a setting value as ctx.settings.<settingName>
.
For more information about using app settings in the JS code and code samples, see Using Setting Values in the Scripts.
Define App Settings
To define custom app settings, add a file named settings.json
to the app package. The settings.json
file must comply to the JSON Schema 2020-12 to be validated on the YouTrack side. For more details about the JSON Schema 2020-12, see JSON Schema Docs.
Sample Settings File
Here you can find an example of a settings.json
file of an app.
Supported Setting Types
You can use one of the following entity types for the custom app settings:
string
integer
number
boolean
array
object
Setting Declaration
A settings.json
file has the following fields:
Field | Type | Description | Required |
---|---|---|---|
type | string | The type of the entity that is located at the root of the | ✓ |
title | string | The title of the file with the setting declaration. This title is displayed on the Settings tab of the app. You can use this title to give app users more information about the settings that this app allows to configure. |
|
description | string | The description of the file with the setting declaration. It is displayed under the title on the Settings tab of the app. You can use this description to give app users more details and context about the settings that this app allows to configure. |
|
properties | object | An object that contains definitions of app settings. | ✓ |
required | Array.<string> | An array of properties that represent required app settings. |
|
Properties
Each app setting must be declared as a field of the properties
object in the settings.json
file.
Each key of the properties
object represents the key name of a setting, while the field value is an object defining the setting.
YouTrack apps support property parameters from the JSON Schema Draft 07.
Properties are defined with the following parameters:
Parameter | Type | Description | Required | ||||||
---|---|---|---|---|---|---|---|---|---|
const | any | The value that the property is restricted to. |
| ||||||
description | string | The description of the setting. It will be displayed in the UI as a text label under the setting. |
| ||||||
enum | Array.<any> | Defines a closed list of values that the user will be able to choose from. Each element of the list must be unique. |
| ||||||
exclusiveMaximum | number | The exclusive upper limit for a numeric value. This parameter is only applicable to settings of the |
| ||||||
exclusiveMinimum | number | The exclusive lower limit for a numeric value. This parameter is only applicable to settings of the |
| ||||||
format | string | The format of the expected value. YouTrack apps support formats from the JSON Schema Draft 07. Here you can find more details about some of the available formats:
|
| ||||||
items | object | This parameter must be used for the |
| ||||||
maximum | number | The non-exclusive upper limit for the values that are allowed for this setting. This parameter is only applicable to settings of the |
| ||||||
maxLength | integer | The maximal length of the string that this setting accepts. This parameter is only applicable to settings of the |
| ||||||
minimum | number | The non-exclusive lower limit for the values that are allowed for this setting. This parameter is only applicable to settings of the |
| ||||||
minItems | integer | The minimal number of items in the array. This parameter is only applicable to settings of the To make an |
| ||||||
minLength | integer | The minimal length of the string that this setting accepts. This parameter is only applicable to settings of the |
| ||||||
multipleOf | number | A value is valid only if division by this parameter's value results in an integer. The value must be strictly greater than 0. This parameter is only applicable to settings of |
| ||||||
readOnly | boolean | When |
| ||||||
title | string | The name of the setting as it will be displayed in the app settings in the YouTrack UI. | ✓ | ||||||
type | string | The type of the entity expected as the setting value. The following types are allowed:
The | ✓ | ||||||
x-entity | string | This parameter refers to YouTrack core entities that you can use in the app settings. This is a special setting parameter that can only be used for settings of the For the For more details, see Using YouTrack Entities for Setting Values. |
| ||||||
x-scope | string | Defines the scope of the setting. Possible values:
|
|
Arrays
Each array
-typed property must be defined with the following parameters:
Parameter | Type | Description | Required |
---|---|---|---|
x-entity | string | This parameter refers to YouTrack core entities that you can use in arrays in the app settings. This is a special setting parameter that can only be used for settings of the For the | ✓ |
type | string | Defines the type of the parameter. For the | ✓ |
Using YouTrack Entities for Setting Values
In app settings with array
and object
types, you can use some of the core YouTrack entities for the setting values. The x-entity
setting parameter defines the exact type of the YouTrack entity that the app expects in a particular setting.
You can use the following YouTrack entities in the app settings:
Issue
Article
Project
User
UserGroup
Configuring Values for App Settings
When you’re configuring an installed app in YouTrack, you can provide settings for the app on the global or project level. Settings configured on the project level have higher priority and overwrite the global settings. If you don't set any project-level values for app settings, the global-level values for these settings are applied.
To set values for app settings on the global level:
From the Administration menu, select Apps.
Select the target app from the list.
Open the Settings tab for this app.
Update values for the settings of the app.
When ready, click the Save button.
The values for the app settings are saved on the global level.
The values are updated in all projects where this app is attached and where the app settings are synchronized with the global app settings.
To set values for app settings on the project level:
In the project settings, open the Apps tab.
Select the target app from the list.
Open the Settings tab for this app.
Set values for the settings of the app.
When ready, click the Save button.
The values for the app settings are saved on the project level.
The values you've just set overwrite any global-level values for these settings.
The settings that you've updated stop being synchronized with the global app settings.
Working with Settings for Secrets
When you declare a setting that is formatted to store a secret
, YouTrack handles values stored in the setting differently than it does for other settings. These values are stored securely, ensuring that only authorized parts of the application can access them. This means users can store their authentication tokens and credentials for authorizing the app without having this information fall into the hands of others.
YouTrack handles values stored as secrets in the following manner:
- Once a secret has been stored, no one else can read it anywhere in YouTrack. The real value is used only in the
http.js
package when it is needed to authenticate an HTTP request, namely:bearer token authentication flows. For an example, see Using Setting Values in the Scripts below.
addHeader and setHeader methods. For example,
for example, connection.addHeader('My-Token-Header', ctx.settings.secretToken)
as the value for a
queryParam
parameter in methods like getSync and others. For example,connection.getSync(url, { apiKey: ctx.settings.apiKey) }
, theapiKey
is stored as a secret.
HTTP requests sent using the
http.js
package are processed inside the JVM, so values stored in secret settings don't appear anywhere in logs.
Using Setting Values in the Scripts
You can refer to a setting value as ctx.settings.<settingName>
in any JavaScript-based script within the app package. For example, you can use setting values in HTTP handlers, workflow rules, import scripts, and other JS scripts.
Here is a code sample for using setting values in an HTTP handler:
Here is a code sample for an HTTP handler that uses a setting of the secret
format: