debian-mirror-gitlab/doc/api/templates/gitlab_ci_ymls.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

153 lines
4.8 KiB
Markdown
Raw Normal View History

2019-12-04 20:38:33 +05:30
---
2020-10-24 23:57:45 +05:30
stage: Verify
2021-09-04 01:27:46 +05:30
group: Pipeline Authoring
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-12-04 20:38:33 +05:30
type: reference
---
2022-07-23 23:45:48 +05:30
# GitLab CI YAMLs API **(FREE)**
2016-11-03 12:29:30 +05:30
2022-07-23 23:45:48 +05:30
In GitLab, there is an API endpoint available to work with GitLab CI/CD YAMLs. For more
2019-12-04 20:38:33 +05:30
information on CI/CD pipeline configuration in GitLab, see the
2021-09-30 23:02:18 +05:30
[configuration reference documentation](../../ci/yaml/index.md).
2019-12-04 20:38:33 +05:30
2020-10-24 23:57:45 +05:30
## List GitLab CI YAML templates
2016-11-03 12:29:30 +05:30
2020-10-24 23:57:45 +05:30
Get all GitLab CI/CD YAML templates.
2016-11-03 12:29:30 +05:30
2019-12-21 20:55:43 +05:30
```plaintext
2016-11-03 12:29:30 +05:30
GET /templates/gitlab_ci_ymls
```
2019-12-21 20:55:43 +05:30
Example request:
2020-03-13 15:44:24 +05:30
```shell
2020-10-24 23:57:45 +05:30
curl "https://gitlab.example.com/api/v4/templates/gitlab_ci_ymls"
2016-11-03 12:29:30 +05:30
```
Example response:
```json
[
{
2018-12-05 23:21:45 +05:30
"key": "Android",
"name": "Android"
2016-11-03 12:29:30 +05:30
},
2019-12-21 20:55:43 +05:30
{
"key": "Android-Fastlane",
"name": "Android-Fastlane"
},
2016-11-03 12:29:30 +05:30
{
2018-12-05 23:21:45 +05:30
"key": "Auto-DevOps",
"name": "Auto-DevOps"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Bash",
"name": "Bash"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "C++",
"name": "C++"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Chef",
"name": "Chef"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Clojure",
"name": "Clojure"
2016-11-03 12:29:30 +05:30
},
2019-12-21 20:55:43 +05:30
{
"key": "Code-Quality",
"name": "Code-Quality"
},
2016-11-03 12:29:30 +05:30
{
2018-12-05 23:21:45 +05:30
"key": "Crystal",
"name": "Crystal"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Django",
"name": "Django"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Docker",
"name": "Docker"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Elixir",
"name": "Elixir"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Go",
"name": "Go"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Gradle",
"name": "Gradle"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Grails",
"name": "Grails"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Julia",
"name": "Julia"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "LaTeX",
"name": "LaTeX"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Laravel",
"name": "Laravel"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Maven",
"name": "Maven"
2016-11-03 12:29:30 +05:30
},
{
2018-12-05 23:21:45 +05:30
"key": "Mono",
"name": "Mono"
2016-11-03 12:29:30 +05:30
}
]
```
2020-10-24 23:57:45 +05:30
## Single GitLab CI YAML template
2016-11-03 12:29:30 +05:30
2020-10-24 23:57:45 +05:30
Get a single GitLab CI/CD YAML template.
2016-11-03 12:29:30 +05:30
2019-12-21 20:55:43 +05:30
```plaintext
2016-11-03 12:29:30 +05:30
GET /templates/gitlab_ci_ymls/:key
```
2019-12-21 20:55:43 +05:30
| Attribute | Type | Required | Description |
| ---------- | ------ | -------- | ------------------------------------- |
2020-10-24 23:57:45 +05:30
| `key` | string | yes | The key of the GitLab CI/CD YAML template |
2016-11-03 12:29:30 +05:30
2019-12-21 20:55:43 +05:30
Example request:
2020-03-13 15:44:24 +05:30
```shell
2020-10-24 23:57:45 +05:30
curl "https://gitlab.example.com/api/v4/templates/gitlab_ci_ymls/Ruby"
2016-11-03 12:29:30 +05:30
```
Example response:
```json
{
"name": "Ruby",
2022-07-23 23:45:48 +05:30
"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/index.html\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, e.g. 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"
2016-11-03 12:29:30 +05:30
}
```
2019-12-04 20:38:33 +05:30
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->