그룹 레벨 변수 API

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated

그룹 변수 목록

그룹의 변수 목록을 가져옵니다.

GET /groups/:id/variables
속성 타입 필수 설명
id integer/string Yes 그룹의 ID 또는 URL-인코딩 된 그룹 경로
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/variables"
[
    {
        "key": "TEST_VARIABLE_1",
        "variable_type": "env_var",
        "value": "TEST_1",
        "protected": false,
        "masked": false,
        "raw": false,
        "environment_scope": "*",
        "description": null
    },
    {
        "key": "TEST_VARIABLE_2",
        "variable_type": "env_var",
        "value": "TEST_2",
        "protected": false,
        "masked": false,
        "raw": false,
        "environment_scope": "*",
        "description": null
    }
]

변수 세부 정보 보기

그룹의 특정 변수 세부 정보를 가져옵니다. 동일한 키를 가진 여러 변수가 있는 경우, 올바른 environment_scope를 선택하기 위해 filter를 사용하세요.

GET /groups/:id/variables/:key
속성 타입 필수 설명
id integer/string Yes 그룹의 ID 또는 URL-인코딩 된 그룹 경로
key string Yes 변수의 key
filter hash No 사용 가능한 필터: [environment_scope]. filter 매개변수 세부 정보를 참조하세요.
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/variables/TEST_VARIABLE_1"
{
    "key": "TEST_VARIABLE_1",
    "variable_type": "env_var",
    "value": "TEST_1",
    "protected": false,
    "masked": false,
    "raw": false,
    "environment_scope": "*",
    "description": null
}

변수 생성

새 변수를 생성합니다.

POST /groups/:id/variables
속성 타입 필수 설명
id integer/string Yes 그룹의 ID 또는 URL-인코딩 된 그룹 경로.
key string Yes 변수의 key; 255자를 초과해서는 안 됨; A-Z, a-z, 0-9, _만 허용됨.
value string Yes 변수의 value.
description string No 변수의 description. 기본: null.
environment_scope string No 변수의 환경 범위. 프리미엄 및 얼티밋 전용.
masked boolean No 변수가 마스킹되었는지 여부.
protected boolean No 변수가 보호되는지 여부.
raw boolean No 변수가 로우 문자열로 처리되는지 여부. 기본: false. true일 때 값의 변수는 확장되지 않습니다.
variable_type string No 변수의 유형. 사용 가능한 유형: env_var (기본값) 및 file.
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/1/variables" --form "key=NEW_VARIABLE" --form "value=new value"
{
    "key": "NEW_VARIABLE",
    "value": "new value",
    "variable_type": "env_var",
    "protected": false,
    "masked": false,
    "raw": false,
    "environment_scope": "*",
    "description": null
}

변수 업데이트

  • filter 매개변수는 GitLab 16.9에서 도입되었습니다.

그룹의 변수를 업데이트합니다. 동일한 키를 가진 여러 변수가 있는 경우 filter를 사용하여 올바른 environment_scope를 선택합니다.

PUT /groups/:id/variables/:key
속성 유형 필수 설명
id 정수/문자열 그룹 ID 또는 URL-encoded path of the group
key 문자열 변수의 key
value 문자열 변수의 value
description 문자열 아니오 변수의 설명. 기본값: null. GitLab 16.2에서 도입되었습니다.
environment_scope 문자열 아니오 변수의 환경 범위. 프리미엄 및 얼티밋 전용.
filter 해시 아니오 사용 가능한 필터: [environment_scope]. filter parameter details를 참조하십시오.
masked 부울 아니오 변수가 마스킹되었는지 여부
protected 부울 아니오 변수가 보호되었는지 여부
raw 부울 아니오 변수가 로우 문자열로 처리되는지 여부. 기본값: false. true일 때 값의 변수는 expanded되지 않습니다.
variable_type 문자열 아니오 변수의 유형. 사용 가능한 유형은: env_var (기본값) 및 file
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/1/variables/NEW_VARIABLE" --form "value=updated value"
{
    "key": "NEW_VARIABLE",
    "value": "updated value",
    "variable_type": "env_var",
    "protected": true,
    "masked": true,
    "raw": true,
    "environment_scope": "*",
    "description": null
}

변수 제거

  • filter 매개변수는 GitLab 16.9에서 도입되었습니다.

그룹의 변수를 제거합니다. 동일한 키를 가진 여러 변수가 있는 경우 filter를 사용하여 올바른 environment_scope를 선택합니다.

DELETE /groups/:id/variables/:key
속성 유형 필수 설명
id 정수/문자열 그룹 ID 또는 URL-encoded path of the group
key 문자열 변수의 key
filter 해시 아니오 사용 가능한 필터: [environment_scope]. filter parameter details를 참조하십시오.
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/1/variables/VARIABLE_1"

filter 매개변수

상세 내용: Tier: 프리미엄, 얼티밋 Offering: GitLab.com, Self-managed, GitLab Dedicated

  • GitLab 16.9에서 도입되었습니다.

동일한 key를 가진 여러 변수가 있는 경우 GET, PUT, 또는 DELETE 요청은 다음을 반환할 수 있습니다:

제공된 매개변수로 여러 변수가 있습니다. 'filter[environment_scope]'를 사용하십시오.

filter[environment_scope]를 사용하여 일치하는 environment_scope 속성을 가진 변수를 선택합니다.

예:

  • GET:

    curl --globoff --header "PRIVATE-TOKEN: <your_access_token>" \
         "https://gitlab.example.com/api/v4/groups/1/variables/SCOPED_VARIABLE_1?filter[environment_scope]=production"
    
  • PUT:

    curl --request PUT --globoff --header "PRIVATE-TOKEN: <your_access_token>" \
         "https://gitlab.example.com/api/v4/groups/1/variables/SCOPED_VARIABLE_1?value=scoped-variable-updated-value&environment_scope=production&filter[environment_scope]=production"
    
  • DELETE:

    curl --request DELETE --globoff --header "PRIVATE-TOKEN: <your_access_token>" \
         "https://gitlab.example.com/api/v4/groups/1/variables/SCOPED_VARIABLE_1?filter[environment_scope]=production"