@@ -22,6 +22,7 @@ type Config struct {
22
22
// Notifier is a notification notifier
23
23
type Notifier struct {
24
24
Github GithubNotifier `yaml:"github"`
25
+ Gitlab GitlabNotifier `yaml:"gitlab"`
25
26
Slack SlackNotifier `yaml:"slack"`
26
27
Typetalk TypetalkNotifier `yaml:"typetalk"`
27
28
}
@@ -33,6 +34,13 @@ type GithubNotifier struct {
33
34
Repository Repository `yaml:"repository"`
34
35
}
35
36
37
+ // GitlabNotifier is a notifier for GitLab
38
+ type GitlabNotifier struct {
39
+ Token string `yaml:"token"`
40
+ BaseURL string `yaml:"base_url"`
41
+ Repository Repository `yaml:"repository"`
42
+ }
43
+
36
44
// Repository represents a GitHub repository
37
45
type Repository struct {
38
46
Owner string `yaml:"owner"`
@@ -98,6 +106,8 @@ func (cfg *Config) Validation() error {
98
106
return errors .New ("ci: need to be set" )
99
107
case "circleci" , "circle-ci" :
100
108
// ok pattern
109
+ case "gitlabci" , "gitlab-ci" :
110
+ // ok pattern
101
111
case "travis" , "travisci" , "travis-ci" :
102
112
// ok pattern
103
113
case "codebuild" :
@@ -119,6 +129,14 @@ func (cfg *Config) Validation() error {
119
129
return fmt .Errorf ("repository name is missing" )
120
130
}
121
131
}
132
+ if cfg .isDefinedGitlab () {
133
+ if cfg .Notifier .Gitlab .Repository .Owner == "" {
134
+ return fmt .Errorf ("repository owner is missing" )
135
+ }
136
+ if cfg .Notifier .Gitlab .Repository .Name == "" {
137
+ return fmt .Errorf ("repository name is missing" )
138
+ }
139
+ }
122
140
if cfg .isDefinedSlack () {
123
141
if cfg .Notifier .Slack .Channel == "" {
124
142
return fmt .Errorf ("slack channel id is missing" )
@@ -141,6 +159,11 @@ func (cfg *Config) isDefinedGithub() bool {
141
159
return cfg .Notifier .Github != (GithubNotifier {})
142
160
}
143
161
162
+ func (cfg * Config ) isDefinedGitlab () bool {
163
+ // not empty
164
+ return cfg .Notifier .Gitlab != (GitlabNotifier {})
165
+ }
166
+
144
167
func (cfg * Config ) isDefinedSlack () bool {
145
168
// not empty
146
169
return cfg .Notifier .Slack != (SlackNotifier {})
@@ -156,6 +179,9 @@ func (cfg *Config) GetNotifierType() string {
156
179
if cfg .isDefinedGithub () {
157
180
return "github"
158
181
}
182
+ if cfg .isDefinedGitlab () {
183
+ return "gitlab"
184
+ }
159
185
if cfg .isDefinedSlack () {
160
186
return "slack"
161
187
}
0 commit comments