summaryrefslogtreecommitdiff
path: root/doc/api/templates/gitlab_ci_ymls.md
blob: e120016fbe6b1b17fe66bbf4f29c52e50132f2d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# GitLab CI YMLs

## List GitLab CI YML templates

Get all GitLab CI YML templates.

```
GET /templates/gitlab_ci_ymls
```

```bash
curl https://gitlab.example.com/api/v3/templates/gitlab_ci_ymls
```

Example response:

```json
[
  {
    "name": "C++"
  },
  {
    "name": "Docker"
  },
  {
    "name": "Elixir"
  },
  {
    "name": "LaTeX"
  },
  {
    "name": "Grails"
  },
  {
    "name": "Rust"
  },
  {
    "name": "Nodejs"
  },
  {
    "name": "Ruby"
  },
  {
    "name": "Scala"
  },
  {
    "name": "Maven"
  },
  {
    "name": "Harp"
  },
  {
    "name": "Pelican"
  },
  {
    "name": "Hyde"
  },
  {
    "name": "Nanoc"
  },
  {
    "name": "Octopress"
  },
  {
    "name": "JBake"
  },
  {
    "name": "HTML"
  },
  {
    "name": "Hugo"
  },
  {
    "name": "Metalsmith"
  },
  {
    "name": "Hexo"
  },
  {
    "name": "Lektor"
  },
  {
    "name": "Doxygen"
  },
  {
    "name": "Brunch"
  },
  {
    "name": "Jekyll"
  },
  {
    "name": "Middleman"
  }
]
```

## Single GitLab CI YML template

Get a single GitLab CI YML template.

```
GET /templates/gitlab_ci_ymls/:key
```

| Attribute  | Type   | Required | Description |
| ---------- | ------ | -------- | ----------- |
| `key`      | string | yes      | The key of the GitLab CI YML template |

```bash
curl https://gitlab.example.com/api/v3/templates/gitlab_ci_ymls/Ruby
```

Example response:

```json
{
  "name": "Ruby",
  "content": "# This file is a template, and might need editing before it works on your project.\n# Official language image. Look for the different tagged releases at:\n# https://hub.docker.com/r/library/ruby/tags/\nimage: \"ruby:2.3\"\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: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service\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 && apt-get install nodejs -yqq\n  - gem install bundler  --no-ri --no-rdoc    # Bundler is not installed with the image\n  - bundle install -j $(nproc) --path vendor  # Install dependencies into ./vendor/ruby\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  - bundle exec rake db:migrate\n  - bundle exec rake db:seed\n  - bundle exec rake test\n"
}
```