@@ -93,14 +93,19 @@ loopNotif:
93
93
repoFullName := wr .Workflow .Applications [node .Context .ApplicationID ].RepositoryFullname
94
94
95
95
//Get the RepositoriesManager Client
96
+ log .Info (ctx , "######## SendVCSEvent: AAAA" )
96
97
if e .vcsClient == nil {
98
+ log .Info (ctx , "######## SendVCSEvent: BBBBB" )
97
99
var err error
98
100
e .vcsClient , err = repositoriesmanager .AuthorizedClient (ctx , tx , store , proj .Key , vcsServerName )
99
101
if err != nil {
100
- return err
102
+ log .Info (ctx , "######## SendVCSEvent: CCCC" )
103
+ return sdk .WrapError (err , "can't get AuthorizedClient for %v/%v" , proj .Key , vcsServerName )
101
104
}
105
+ log .Info (ctx , "######## SendVCSEvent: DDDDD" )
102
106
}
103
107
108
+ log .Info (ctx , "######## SendVCSEvent: EEEEE" )
104
109
ref := nodeRun .VCSHash
105
110
if nodeRun .VCSTag != "" {
106
111
ref = nodeRun .VCSTag
@@ -111,7 +116,7 @@ loopNotif:
111
116
var err error
112
117
statuses , err = e .vcsClient .ListStatuses (ctx , repoFullName , ref )
113
118
if err != nil {
114
- return err
119
+ return sdk . WrapError ( err , "can't ListStatuses for %v with vcs %v/%v" , repoFullName , proj . Key , vcsServerName )
115
120
}
116
121
e .commitsStatuses [ref ] = statuses
117
122
}
@@ -129,7 +134,7 @@ loopNotif:
129
134
130
135
if statusFound == nil || statusFound .State == "" {
131
136
if err := e .sendVCSEventStatus (ctx , tx , store , proj .Key , wr , & nodeRun , notif , vcsServerName ); err != nil {
132
- return err
137
+ return sdk . WrapError ( err , "can't sendVCSEventStatus vcs %v/%v" , proj . Key , vcsServerName )
133
138
}
134
139
} else {
135
140
skipStatus := false
@@ -154,7 +159,7 @@ loopNotif:
154
159
155
160
if ! skipStatus {
156
161
if err := e .sendVCSEventStatus (ctx , tx , store , proj .Key , wr , & nodeRun , notif , vcsServerName ); err != nil {
157
- return err
162
+ return sdk . WrapError ( err , "can't sendVCSEventStatus vcs %v/%v" , proj . Key , vcsServerName )
158
163
}
159
164
}
160
165
}
@@ -163,7 +168,7 @@ loopNotif:
163
168
return nil
164
169
}
165
170
if err := e .sendVCSPullRequestComment (ctx , tx , wr , & nodeRun , notif , vcsServerName ); err != nil {
166
- return err
171
+ return sdk . WrapError ( err , "can't sendVCSPullRequestComment vcs %v/%v" , proj . Key , vcsServerName )
167
172
}
168
173
169
174
if err := tx .Commit (); err != nil {
@@ -237,12 +242,11 @@ func (e *VCSEventMessenger) sendVCSEventStatus(ctx context.Context, db gorp.SqlE
237
242
}
238
243
239
244
// Check if it's a gerrit or not
240
- vcsConf , err := repositoriesmanager . LoadByName (ctx , db , vcsServerName )
245
+ isGerrit , err := e . vcsClient . IsGerrit (ctx , db )
241
246
if err != nil {
242
247
return err
243
248
}
244
-
245
- if vcsConf .Type == "gerrit" {
249
+ if isGerrit {
246
250
// Get gerrit variable
247
251
var project , changeID , branch , revision , url string
248
252
projectParam := sdk .ParameterFind (nodeRun .BuildParameters , "git.repository" )
@@ -275,7 +279,6 @@ func (e *VCSEventMessenger) sendVCSEventStatus(ctx context.Context, db gorp.SqlE
275
279
URL : url ,
276
280
}
277
281
}
278
-
279
282
}
280
283
281
284
payload , _ := json .Marshal (eventWNR )
@@ -329,12 +332,6 @@ func (e *VCSEventMessenger) sendVCSPullRequestComment(ctx context.Context, db go
329
332
return err
330
333
}
331
334
332
- // Check if it's a gerrit or not
333
- vcsConf , err := repositoriesmanager .LoadByName (ctx , db , vcsServerName )
334
- if err != nil {
335
- return err
336
- }
337
-
338
335
var changeID string
339
336
changeIDParam := sdk .ParameterFind (nodeRun .BuildParameters , "gerrit.change.id" )
340
337
if changeIDParam != nil {
@@ -350,13 +347,17 @@ func (e *VCSEventMessenger) sendVCSPullRequestComment(ctx context.Context, db go
350
347
reqComment := sdk.VCSPullRequestCommentRequest {Message : report }
351
348
reqComment .Revision = revision
352
349
353
- // If we are on Gerrit
354
- if changeID != "" && vcsConf .Type == "gerrit" {
350
+ isGerrit , err := e .vcsClient .IsGerrit (ctx , db )
351
+ if err != nil {
352
+ return err
353
+ }
354
+
355
+ if changeID != "" && isGerrit {
355
356
reqComment .ChangeID = changeID
356
357
if err := e .vcsClient .PullRequestComment (ctx , app .RepositoryFullname , reqComment ); err != nil {
357
358
return err
358
359
}
359
- } else if vcsConf . Type != "gerrit" {
360
+ } else if ! isGerrit {
360
361
//Check if this branch and this commit is a pullrequest
361
362
prs , err := e .vcsClient .PullRequests (ctx , app .RepositoryFullname )
362
363
if err != nil {
0 commit comments