summaryrefslogtreecommitdiff
path: root/doc/builds_configuration/README.md
blob: f7405d7cbe293afcf51cd7d99270c0a7861e46e3 (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
## 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 placed in the root of your repository and contains three type of objects: before_script, builds and deploy_builds. Here is an example of how it looks:

```yaml
before_script: 
  - gem install bundler
  - bundle install 
  - bundle exec rake db:create

rspec: 
  script: "rake spec"
  tags: 
    - ruby
    - postgres
  only: 
    - branches

staging: 
  script: "cap deploy stating"
  type: deploy
  tags: 
    - capistrano
    - debian
  except:
    - stable
    - /^deploy-.*$/

```

Let's have a close look at each section.

### builds
Here you can specify parameters of your builds:

```yaml
rspec: 
  script: "rake spec"  # (required) - shell command for runner
  tags:                # (optional) - runner tags, only runners which have these tags will be used
    - ruby
    - postgres
  only:                # (optional) - git refs (branches and tags)
    - master

```

`rspec` is a key of this object and it determines the name of your build

`script` is a shell script which is used by runner. It will be also prepanded with `before_script`. This parameter can also cantain several commands using array:

```yaml
script:
  - uname -a
  - bundle exec rspec
```
About `only` and `except` parameters you can read in the [refs settings explanation](#refs-settings-explanation)

### deploy_builds
Deploy Builds that will be run when all other builds have succeeded. Define them using simple syntax:

```yaml
production: 
  script: "cap deploy production" # (required) - shell command for runner
  type: deploy
  tags: 
    - ruby
    - postgres
  only:
    - master
```
`production` - is a name of deploy build.
`script` - is a shell script which will be prepended with `before_script`.
`type: deploy` is a parameter which indicates that it is a deploy job
About `only` and `except` parameters you can read in the [refs settings explanation](#refs-settings-explanation)

### 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.

### Refs settings explanation
There are two parameters that help you to set up refs policy for your build or deploy build on CI.
```
only:
  - master
```
`only` defines exact name of the branch or the tag which will be run. It also supports the regexp expressions:

```
only:
  - /^issue-.*$/
```
You can also use an `except` parameter:
```
except:
  - "deploy"
```
This parameter is used for excluding some refs. It is also supporting regexp expressions.

There are also special keys like `branches` or `tags`. These parameters can be used for excluding all tags or branches.
```
except:
  - branches
```

## 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`.