프로젝트 템플릿 API

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

이 API는 다음 Endpoints의 프로젝트별 버전입니다.

이 API 버전 5에서 제거 예정인 이러한 Endpoints를 더 이상 사용하지 않습니다.

인스턴스 전반에 걸친 템플릿 외에도 프로젝트별 템플릿을 이 API 엔드포인트에서 사용할 수 있습니다.

그룹 레벨 파일 템플릿에 대한 지원도 가능합니다.

특정 유형의 모든 템플릿 가져오기

GET /projects/:id/templates/:type
속성 유형 필수 설명
id 정수 또는 문자열 프로젝트의 ID 또는 URL 인코딩된 경로.
type 문자열 템플릿의 유형. 허용된 값은: dockerfiles, gitignores, gitlab_ci_ymls, licenses, issues, 또는 merge_requests.

예시 응답 (라이선스):

[
  {
    "key": "epl-1.0",
    "name": "Eclipse Public License 1.0"
  },
  {
    "key": "lgpl-3.0",
    "name": "GNU Lesser General Public License v3.0"
  },
  {
    "key": "unlicense",
    "name": "The Unlicense"
  },
  {
    "key": "agpl-3.0",
    "name": "GNU Affero General Public License v3.0"
  },
  {
    "key": "gpl-3.0",
    "name": "GNU General Public License v3.0"
  },
  {
    "key": "bsd-3-clause",
    "name": "BSD 3-clause \"New\" or \"Revised\" License"
  },
  {
    "key": "lgpl-2.1",
    "name": "GNU Lesser General Public License v2.1"
  },
  {
    "key": "mit",
    "name": "MIT License"
  },
  {
    "key": "apache-2.0",
    "name": "Apache License 2.0"
  },
  {
    "key": "bsd-2-clause",
    "name": "BSD 2-clause \"Simplified\" License"
  },
  {
    "key": "mpl-2.0",
    "name": "Mozilla Public License 2.0"
  },
  {
    "key": "gpl-2.0",
    "name": "GNU General Public License v2.0"
  }
]

특정 유형의 하나의 템플릿 가져오기

GET /projects/:id/templates/:type/:name
속성 유형 필수 설명
id 정수 또는 문자열 프로젝트의 ID 또는 URL 인코딩된 경로.
name 문자열 컬렉션 엔드포인트에서 얻은 템플릿의 키.
type 문자열 템플릿의 유형. 다음 중 하나: dockerfiles, gitignores, gitlab_ci_ymls, licenses, issues, 또는 merge_requests.
fullname 문자열 아니오 템플릿 내의 플레이스홀더를 확장할 때 사용할 저작권 보유자의 전체 이름. 라이선스에만 영향을 미침.
project 문자열 아니오 템플릿 내의 플레이스홀더를 확장할 때 사용할 프로젝트 이름. 라이선스에만 영향을 미침.
source_template_project_id 정수 아니오 특정 템플릿이 저장되는 프로젝트 ID. 서로 다른 프로젝트에서 여러 템플릿이 같은 이름을 가지고 있을 때 유용함. source_template_project_id가 지정되지 않으면, 가장 가까운 조상에서 일치하는 템플릿이 반환됨.

예시 응답 (Dockerfile):

{
  "name": "Binary",
  "content": "# This file is a template, and might need editing before it works on your project.\n# This Dockerfile installs a compiled binary into a bare system.\n# You must either commit your compiled binary into source control (not recommended)\n# or build the binary first as part of a CI/CD pipeline.\n\nFROM buildpack-deps:buster\n\nWORKDIR /usr/local/bin\n\n# Change `app` to whatever your binary is called\nAdd app .\nCMD [\"./app\"]\n"
}

예시 응답 (라이선스):

{
  "key": "mit",
  "name": "MIT License",
  "nickname": null,
  "popular": true,
  "html_url": "http://choosealicense.com/licenses/mit/",
  "source_url": "https://opensource.org/licenses/MIT",
  "description": "A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.",
  "conditions": [
    "include-copyright"
  ],
  "permissions": [
    "commercial-use",
    "modifications",
    "distribution",
    "private-use"
  ],
  "limitations": [
    "liability",
    "warranty"
  ],
  "content": "MIT License\n\nCopyright (c) 2018 [fullname]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
}