blob: 06c2c8e7259c38d308d265380344248713e245f6 (
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
|
## Configuraton of your builds with .gitlab-ci.yml
From version 7.12, GitLab CI uses a .gitlab-ci.yml file for the configuration of your builds. It is place in the root of your repository and contains four main sections: skep_refs, before_script, jobs and deploy_jobs. Here is an example of how it looks:
```yaml
skip_refs: staging
before_script: |
bundle install
bundle exec rake db:setup
jobs:
- script: "bundle exec rspec"
name: Rspec
runner: mysql,ruby
- "bundle exec cucumber" # or even so
deploy_jobs:
- "bundle exec cap deploy"
```
Let's have a close look at each section.
### skip_refs
This parameter defines the ref or list of refs to skip. You can use glob pattern syntax as well. Example: "staging,feature-*"
### jobs
Here you can specify parameters of your builds. There are serveral ways you can configure it. Using hash:
```yaml
jobs:
- script: "bundle exec rspec" # (required) - commands to run
name: Rspec # (optional) - name of build
runner: mysql,ruby # (optional) - runner tags, only runners which have these tags will be used
branches: true # (optional) - make builds for regular branches
tags: true # (optional) - make builds for tags
```
`script` can also cantain several commands using YAML multiline string:
```yaml
- script: |
bundle updata
bundle exec rspec
```
you can also fill commands like an array:
```yaml
- script:
- bundle update
- bundle exec rspec
```
And there is one more way to specify build configuration, using a string:
```yaml
jobs:
- bundle exec rspec
```
In this way, the name of the build will be taken from command line.
### deploy_jobs
Deploy Jobs that will be run when all other jobs have succeeded. Define them using a hash:
```yaml
deploy_jobs:
- script: | # (required) - command
bundle update
bundle exec cap deploy
name: Deploy # (optional) - name
refs: deploy # (optional) - run only when the above git refs strings match the branch or tag that was pushed.
runner: ruby,deploy # (optional) - runner tags, only runners which have these tags will be used
```
`script` can be a multiline script or array like for regular jobs.
You can also define deploy jobs with a string:
```yaml
deploy_jobs:
- "bundle exec cap deploy"
```
### before_script
`before_script` is used to define the command that should be ran before all builds, including deploy builds. This can be an array or a multiline string.
## Debugging of your builds with .gitlab-ci.yml
Each instance of GitLab CI has an embeded debug tool Lint. You can find link to the Lint in the projects settings page or use short url `/lint`.
|