{{< details >}}

  • Tier: 基础版, 专业版, 旗舰版
  • Offering: JihuLab.com, 私有化部署

{{< /details >}}

{{< history >}}

  • 在极狐GitLab 15.7 中 GA。功能标志 ci_secure_files 被移除。

{{< /history >}}

这个功能是Mobile DevOps的一部分。您可以安全地存储多达 100 个文件,以用于 CI/CD 流水线作为安全文件。这些文件安全地存储在项目的代码库之外,并且不进行版本控制。在这些文件中存储敏感信息是安全的。安全文件支持纯文本和二进制文件类型,但必须小于 5 MB。

列出项目安全文件

获取项目中安全文件的列表。

GET /projects/:project_id/secure_files

支持的属性:

属性 类型 必需 描述
project_id integer/string 项目的 ID 或 URL 编码的项目路径

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/secure_files"

示例响应:

[
    {
        "id": 1,
        "name": "myfile.jks",
        "checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
        "checksum_algorithm": "sha256",
        "created_at": "2022-02-22T22:22:22.222Z",
        "expires_at": null,
        "metadata": null
    },
    {
        "id": 2,
        "name": "myfile.cer",
        "checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aa2",
        "checksum_algorithm": "sha256",
        "created_at": "2022-02-22T22:22:22.222Z",
        "expires_at": "2023-09-21T14:55:59.000Z",
        "metadata": {
            "id":"75949910542696343243264405377658443914",
            "issuer": {
                "C":"US",
                "O":"Apple Inc.",
                "CN":"Apple Worldwide Developer Relations Certification Authority",
                "OU":"G3"
            },
            "subject": {
                "C":"US",
                "O":"Organization Name",
                "CN":"Apple Distribution: Organization Name (ABC123XYZ)",
                "OU":"ABC123XYZ",
                "UID":"ABC123XYZ"
            },
            "expires_at":"2023-09-21T14:55:59.000Z"
        }
    }
]

显示安全文件详情

获取项目中特定安全文件的详细信息。

GET /projects/:project_id/secure_files/:id

支持的属性:

属性 类型 必需 描述
id integer 安全文件的 ID。
project_id integer/string 项目的 ID 或 URL 编码的项目路径

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/secure_files/1"

示例响应:

{
    "id": 1,
    "name": "myfile.jks",
    "checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
    "checksum_algorithm": "sha256",
    "created_at": "2022-02-22T22:22:22.222Z",
    "expires_at": null,
    "metadata": null
}

创建安全文件

创建一个新的安全文件。

POST /projects/:project_id/secure_files

支持的属性:

属性 类型 必需 描述
file file 上传的文件(5 MB 限制)。
name string 上传文件的名称。文件名在项目中必须唯一。
project_id integer/string 项目的 ID 或 URL 编码的项目路径

示例请求:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/projects/1/secure_files"  --form "name=myfile.jks" --form "file=@/path/to/file/myfile.jks"

示例响应:

{
    "id": 1,
    "name": "myfile.jks",
    "checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
    "checksum_algorithm": "sha256",
    "created_at": "2022-02-22T22:22:22.222Z",
    "expires_at": null,
    "metadata": null
}

下载安全文件

下载项目安全文件的内容。

GET /projects/:project_id/secure_files/:id/download

支持的属性:

属性 类型 必需 描述
id integer 安全文件的 ID。
project_id integer/string 项目的 ID 或 URL 编码的项目路径

示例请求:

curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/secure_files/1/download --output myfile.jks

删除安全文件

删除项目的安全文件。

DELETE /projects/:project_id/secure_files/:id

支持的属性:

属性 类型 必需 描述
id integer 安全文件的 ID。
project_id integer/string 项目的 ID 或 URL 编码的项目路径

示例请求:

curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/secure_files/1"