极狐GitLab CI YAML API

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

在极狐GitLab 中,有一个 API 端点可用于处理极狐GitLab CI/CD YAML。有关极狐GitLab CI/CD 流水线配置的更多信息,请参见 CI/CD YAML 语法参考

具有访客角色的用户无法访问极狐GitLab CI YAML 模板。有关更多信息,请参阅 项目和群组可见性

列出极狐GitLab CI YAML 模板#

获取所有极狐GitLab CI/CD YAML 模板。

plaintext
GET /templates/gitlab_ci_ymls

示例请求:

shell
curl "https://gitlab.example.com/api/v4/templates/gitlab_ci_ymls"

示例响应:

json
1[ 2 { 3 "key": "Android", 4 "name": "Android" 5 }, 6 { 7 "key": "Android-Fastlane", 8 "name": "Android-Fastlane" 9 }, 10 { 11 "key": "Auto-DevOps", 12 "name": "Auto-DevOps" 13 }, 14 { 15 "key": "Bash", 16 "name": "Bash" 17 }, 18 { 19 "key": "C++", 20 "name": "C++" 21 }, 22 { 23 "key": "Chef", 24 "name": "Chef" 25 }, 26 { 27 "key": "Clojure", 28 "name": "Clojure" 29 }, 30 { 31 "key": "Code-Quality", 32 "name": "Code-Quality" 33 }, 34 { 35 "key": "Crystal", 36 "name": "Crystal" 37 }, 38 { 39 "key": "Django", 40 "name": "Django" 41 }, 42 { 43 "key": "Docker", 44 "name": "Docker" 45 }, 46 { 47 "key": "Elixir", 48 "name": "Elixir" 49 }, 50 { 51 "key": "Go", 52 "name": "Go" 53 }, 54 { 55 "key": "Gradle", 56 "name": "Gradle" 57 }, 58 { 59 "key": "Grails", 60 "name": "Grails" 61 }, 62 { 63 "key": "Julia", 64 "name": "Julia" 65 }, 66 { 67 "key": "LaTeX", 68 "name": "LaTeX" 69 }, 70 { 71 "key": "Laravel", 72 "name": "Laravel" 73 }, 74 { 75 "key": "Maven", 76 "name": "Maven" 77 }, 78 { 79 "key": "Mono", 80 "name": "Mono" 81 } 82]

单个极狐GitLab CI YAML 模板#

获取单个极狐GitLab CI/CD YAML 模板。

plaintext
GET /templates/gitlab_ci_ymls/:key
属性类型是否必需描述
keystring极狐GitLab CI/CD YAML 模板的键

示例请求:

shell
curl "https://gitlab.example.com/api/v4/templates/gitlab_ci_ymls/Ruby"

示例响应:

json
{ "name": "Ruby", "content": "# This file is a template, and might need editing before it works on your project.\n# To contribute improvements to CI/CD templates, please follow the Development guide at:\n# https://docs.gitlab.com/ee/development/cicd/templates.html\n# This specific template is located at:\n# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml\n\n# Official language image. Look for the different tagged releases at:\n# https://hub.docker.com/r/library/ruby/tags/\nimage: ruby:latest\n\n# Pick zero or more services to be used on all builds.\n# Only needed when using a docker container to run your tests in.\n# Check out: https://docs.gitlab.com/ee/ci/services/\nservices:\n - mysql:latest\n - redis:latest\n - postgres:latest\n\nvariables:\n POSTGRES_DB: database_name\n\n# Cache gems in between builds\ncache:\n paths:\n - vendor/ruby\n\n# This is a basic example for a gem or script which doesn't use\n# services such as redis or postgres\nbefore_script:\n - ruby -v # Print out ruby version for debugging\n # Uncomment next line if your rails app needs a JS runtime:\n # - apt-get update -q \u0026\u0026 apt-get install nodejs -yqq\n - bundle config set --local deployment true # Install dependencies into ./vendor/ruby\n - bundle install -j $(nproc)\n\n# Optional - Delete if not using `rubocop`\nrubocop:\n script:\n - rubocop\n\nrspec:\n script:\n - rspec spec\n\nrails:\n variables:\n DATABASE_URL: \"postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB\"\n script:\n - rails db:migrate\n - rails db:seed\n - rails test\n\n# This deploy job uses a simple deploy flow to Heroku, other providers, for example, AWS Elastic Beanstalk\n# are supported too: https://github.com/travis-ci/dpl\ndeploy:\n stage: deploy\n environment: production\n script:\n - gem install dpl\n - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_PRODUCTION_KEY\n" }