doc-locale/fr-fr/api/instance_level_ci_variables.md
{{< details >}}
{{< /details >}}
Utilisez cette API pour interagir avec les variables CI/CD de votre instance.
{{< history >}}
description introduit dans GitLab 16.8.{{< /history >}}
Répertorie toutes les variables CI/CD au niveau de l'instance. Utilisez les paramètres de pagination page et per_page pour contrôler la pagination des résultats.
GET /admin/ci/variables
curl \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/ci/variables"
[
{
"key": "TEST_VARIABLE_1",
"description": null,
"variable_type": "env_var",
"value": "TEST_1",
"protected": false,
"masked": false,
"raw": false
},
{
"key": "TEST_VARIABLE_2",
"description": null,
"variable_type": "env_var",
"value": "TEST_2",
"protected": false,
"masked": false,
"raw": false
}
]
{{< history >}}
description introduit dans GitLab 16.8.{{< /history >}}
Récupère les détails d'une variable CI/CD au niveau de l'instance spécifique.
GET /admin/ci/variables/:key
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
key | string | Oui | La key d'une variable |
curl \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/ci/variables/TEST_VARIABLE_1"
{
"key": "TEST_VARIABLE_1",
"description": null,
"variable_type": "env_var",
"value": "TEST_1",
"protected": false,
"masked": false,
"raw": false
}
{{< history >}}
description introduit dans GitLab 16.8.{{< /history >}}
Crée une nouvelle variable CI/CD au niveau de l'instance.
Le nombre maximum de variables au niveau de l'instance peut être modifié.
POST /admin/ci/variables
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
key | string | Oui | La key de la variable. Maximum de 255 caractères, seuls A-Z, a-z, 0-9 et _ sont autorisés. |
value | string | Oui | La value de la variable. Maximum de 10 000 caractères. |
description | string | Non | La description de la variable. Maximum de 255 caractères. |
masked | boolean | Non | Indique si la variable est masquée. |
protected | boolean | Non | Indique si la variable est protégée. |
raw | boolean | Non | Indique si la variable est développable. |
variable_type | string | Non | Le type de la variable. Les types disponibles sont : env_var (par défaut) et file. |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/ci/variables" \
--form "key=NEW_VARIABLE" \
--form "value=new value"
{
"key": "NEW_VARIABLE",
"description": null,
"value": "new value",
"variable_type": "env_var",
"protected": false,
"masked": false,
"raw": false
}
{{< history >}}
description introduit dans GitLab 16.8.{{< /history >}}
Met à jour une variable CI/CD au niveau de l'instance.
PUT /admin/ci/variables/:key
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
description | string | Non | La description de la variable. Maximum de 255 caractères. |
key | string | Oui | La key de la variable. Maximum de 255 caractères, seuls A-Z, a-z, 0-9 et _ sont autorisés. |
masked | boolean | Non | Indique si la variable est masquée. |
protected | boolean | Non | Indique si la variable est protégée. |
raw | boolean | Non | Indique si la variable est développable. |
value | string | Oui | La value de la variable. Maximum de 10 000 caractères. |
variable_type | string | Non | Le type de la variable. Les types disponibles sont : env_var (par défaut) et file. |
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/ci/variables/NEW_VARIABLE" \
--form "value=updated value"
{
"key": "NEW_VARIABLE",
"description": null,
"value": "updated value",
"variable_type": "env_var",
"protected": true,
"masked": true,
"raw": true
}
Supprime une variable CI/CD au niveau de l'instance.
DELETE /admin/ci/variables/:key
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
key | string | Oui | La key d'une variable |
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/ci/variables/VARIABLE_1"