-
Notifications
You must be signed in to change notification settings - Fork 616
Expand file tree
/
Copy pathCauseData.java
More file actions
849 lines (775 loc) · 31.1 KB
/
Copy pathCauseData.java
File metadata and controls
849 lines (775 loc) · 31.1 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
package com.dabsquared.gitlabjenkins.cause;
import com.dabsquared.gitlabjenkins.gitlab.api.model.MergeRequest;
import hudson.markup.EscapedMarkupFormatter;
import java.util.*;
import jenkins.model.Jenkins;
import net.karneim.pojobuilder.GeneratePojoBuilder;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
/**
* @author Robin Müller
*/
@ExportedBean
public final class CauseData {
private final ActionType actionType;
private final Integer sourceProjectId;
private final Integer targetProjectId;
private final String branch;
private final String sourceBranch;
private final String userName;
private final String userUsername;
private final String userEmail;
private final String sourceRepoHomepage;
private final String sourceRepoName;
private final String sourceNamespace;
private final String sourceRepoUrl;
private final String sourceRepoSshUrl;
private final String sourceRepoHttpUrl;
private final String mergeCommitSha;
private final String mergeRequestTitle;
private final String mergeRequestDescription;
private final Integer mergeRequestId;
private final Integer mergeRequestIid;
private final String mergeRequestState;
private final String mergedByUser;
private final String mergeRequestAssignee;
private final Integer mergeRequestTargetProjectId;
private final List<String> mergeRequestLabels;
private final String targetBranch;
private final String targetRepoName;
private final String targetNamespace;
private final String targetRepoSshUrl;
private final String targetRepoHttpUrl;
private final String triggeredByUser;
private final String before;
private final String after;
private final String lastCommit;
private final String targetProjectUrl;
private final String triggerPhrase;
private final String ref;
private final String beforeSha;
private final String isTag;
private final String sha;
private final String status;
private final String stages;
private final String createdAt;
private final String finishedAt;
private final String buildDuration;
private final String commentAuthor;
private final Integer pipelineId;
private final Integer pipelineIid;
private final String pipelineSource;
private final String pipelineUrl;
private final String commitMessage;
private final String commitTitle;
private final String commitAuthorName;
private final String commitAuthorEmail;
private final String commitUrl;
private final String projectWebUrl;
private final String projectPathWithNamespace;
@GeneratePojoBuilder(withFactoryMethod = "*")
CauseData(
ActionType actionType,
Integer sourceProjectId,
Integer targetProjectId,
String branch,
String sourceBranch,
String userName,
String userUsername,
String userEmail,
String sourceRepoHomepage,
String sourceRepoName,
String sourceNamespace,
String sourceRepoUrl,
String sourceRepoSshUrl,
String sourceRepoHttpUrl,
String mergeCommitSha,
String mergeRequestTitle,
String mergeRequestDescription,
Integer mergeRequestId,
Integer mergeRequestIid,
Integer mergeRequestTargetProjectId,
List<String> mergeRequestLabels,
String targetBranch,
String targetRepoName,
String targetNamespace,
String targetRepoSshUrl,
String targetRepoHttpUrl,
String triggeredByUser,
String before,
String after,
String lastCommit,
String targetProjectUrl,
String triggerPhrase,
String mergeRequestState,
String mergedByUser,
String mergeRequestAssignee,
String ref,
String isTag,
String sha,
String beforeSha,
String status,
String stages,
String createdAt,
String finishedAt,
String buildDuration,
String commentAuthor,
Integer pipelineId,
Integer pipelineIid,
String pipelineSource,
String pipelineUrl,
String commitMessage,
String commitTitle,
String commitAuthorName,
String commitAuthorEmail,
String commitUrl,
String projectWebUrl,
String projectPathWithNamespace) {
this.actionType = Objects.requireNonNull(actionType, "actionType must not be null.");
this.sourceProjectId = Objects.requireNonNull(sourceProjectId, "sourceProjectId must not be null.");
this.targetProjectId = Objects.requireNonNull(targetProjectId, "targetProjectId must not be null.");
this.branch = Objects.requireNonNull(branch, "branch must not be null.");
this.sourceBranch = Objects.requireNonNull(sourceBranch, "sourceBranch must not be null.");
this.userName = Objects.requireNonNull(userName, "userName must not be null.");
this.userUsername = userUsername == null ? "" : userUsername;
this.userEmail = userEmail == null ? "" : userEmail;
this.sourceRepoHomepage = sourceRepoHomepage == null ? "" : sourceRepoHomepage;
this.sourceRepoName = Objects.requireNonNull(sourceRepoName, "sourceRepoName must not be null.");
this.sourceNamespace = Objects.requireNonNull(sourceNamespace, "sourceNamespace must not be null.");
this.sourceRepoUrl = sourceRepoUrl == null ? sourceRepoSshUrl : sourceRepoUrl;
this.sourceRepoSshUrl = Objects.requireNonNull(sourceRepoSshUrl, "sourceRepoSshUrl must not be null.");
this.sourceRepoHttpUrl = Objects.requireNonNull(sourceRepoHttpUrl, "sourceRepoHttpUrl must not be null.");
this.mergeCommitSha = mergeCommitSha == null ? "" : mergeCommitSha;
this.mergeRequestTitle = Objects.requireNonNull(mergeRequestTitle, "mergeRequestTitle must not be null.");
this.mergeRequestDescription = mergeRequestDescription == null ? "" : mergeRequestDescription;
this.mergeRequestId = mergeRequestId;
this.mergeRequestIid = mergeRequestIid;
this.mergeRequestState = mergeRequestState == null ? "" : mergeRequestState;
this.mergedByUser = mergedByUser == null ? "" : mergedByUser;
this.mergeRequestAssignee = mergeRequestAssignee == null ? "" : mergeRequestAssignee;
this.mergeRequestTargetProjectId = mergeRequestTargetProjectId;
this.mergeRequestLabels = mergeRequestLabels == null ? Collections.emptyList() : mergeRequestLabels;
this.targetBranch = Objects.requireNonNull(targetBranch, "targetBranch must not be null.");
this.targetRepoName = Objects.requireNonNull(targetRepoName, "targetRepoName must not be null.");
this.targetNamespace = Objects.requireNonNull(targetNamespace, "targetNamespace must not be null.");
this.targetRepoSshUrl = Objects.requireNonNull(targetRepoSshUrl, "targetRepoSshUrl must not be null.");
this.targetRepoHttpUrl = Objects.requireNonNull(targetRepoHttpUrl, "targetRepoHttpUrl must not be null.");
this.triggeredByUser = Objects.requireNonNull(triggeredByUser, "triggeredByUser must not be null.");
this.before = before == null ? "" : before;
this.after = after == null ? "" : after;
this.lastCommit = Objects.requireNonNull(lastCommit, "lastCommit must not be null");
this.targetProjectUrl = targetProjectUrl;
this.triggerPhrase = triggerPhrase;
this.ref = ref;
this.isTag = isTag;
this.sha = sha;
this.beforeSha = beforeSha;
this.status = status;
this.stages = stages;
this.createdAt = createdAt;
this.finishedAt = finishedAt;
this.buildDuration = buildDuration;
this.commentAuthor = commentAuthor;
this.pipelineId = pipelineId;
this.pipelineIid = pipelineIid;
this.pipelineSource = pipelineSource;
this.pipelineUrl = pipelineUrl;
this.commitMessage = commitMessage;
this.commitTitle = commitTitle;
this.commitAuthorName = commitAuthorName;
this.commitAuthorEmail = commitAuthorEmail;
this.commitUrl = commitUrl;
this.projectWebUrl = projectWebUrl;
this.projectPathWithNamespace = projectPathWithNamespace;
}
@Exported
public Map<String, String> getBuildVariables() {
MapWrapper<String, String> variables = new MapWrapper<>(new HashMap<String, String>());
variables.put("gitlabBranch", branch);
variables.put("gitlabSourceBranch", sourceBranch);
variables.put("gitlabActionType", actionType.name());
variables.put("gitlabUserName", userName);
variables.put("gitlabUserUsername", userUsername == null ? "" : userUsername);
variables.put("gitlabUserEmail", userEmail);
variables.put("gitlabSourceRepoHomepage", sourceRepoHomepage);
variables.put("gitlabSourceRepoName", sourceRepoName);
variables.put("gitlabSourceNamespace", sourceNamespace);
variables.put("gitlabSourceRepoURL", sourceRepoUrl);
variables.put("gitlabSourceRepoSshUrl", sourceRepoSshUrl);
variables.put("gitlabSourceRepoHttpUrl", sourceRepoHttpUrl);
variables.putIfNotNull("gitlabMergeCommitSha", mergeCommitSha);
variables.put("gitlabMergeRequestTitle", mergeRequestTitle);
variables.put(
"gitlabMergeRequestDescription",
mergeRequestDescription.substring(0, Math.min(mergeRequestDescription.length(), 1000)));
variables.put("gitlabMergeRequestId", mergeRequestId == null ? "" : mergeRequestId.toString());
variables.put("gitlabMergeRequestIid", mergeRequestIid == null ? "" : mergeRequestIid.toString());
variables.put(
"gitlabMergeRequestTargetProjectId",
mergeRequestTargetProjectId == null ? "" : mergeRequestTargetProjectId.toString());
variables.put("gitlabMergeRequestLabels", StringUtils.join(mergeRequestLabels, ","));
variables.put("gitlabMergeRequestLastCommit", lastCommit);
variables.putIfNotNull("gitlabMergeRequestState", mergeRequestState);
variables.putIfNotNull("gitlabMergedByUser", mergedByUser);
variables.putIfNotNull("gitlabMergeRequestAssignee", mergeRequestAssignee);
variables.put("gitlabTargetBranch", targetBranch);
variables.put("gitlabTargetRepoName", targetRepoName);
variables.put("gitlabTargetNamespace", targetNamespace);
variables.put("gitlabTargetRepoSshUrl", targetRepoSshUrl);
variables.put("gitlabTargetRepoHttpUrl", targetRepoHttpUrl);
variables.put("gitlabBefore", before);
variables.put("gitlabAfter", after);
variables.putIfNotNull("gitlabCommentAuthor", commentAuthor);
variables.put("ref", ref);
variables.put("beforeSha", beforeSha);
variables.put("isTag", isTag);
variables.put("sha", sha);
variables.put("status", status);
variables.put("stages", stages);
variables.put("createdAt", createdAt);
variables.put("finishedAt", finishedAt);
variables.put("duration", buildDuration);
variables.putIfNotNull("gitlabTriggerPhrase", triggerPhrase);
variables.putIfNotNull("gitlabPipelineId", pipelineId == null ? null : pipelineId.toString());
variables.putIfNotNull("gitlabPipelineIid", pipelineIid == null ? null : pipelineIid.toString());
variables.putIfNotNull("gitlabPipelineSource", pipelineSource);
variables.putIfNotNull("gitlabPipelineUrl", pipelineUrl);
variables.putIfNotNull("gitlabCommitMessage", commitMessage);
variables.putIfNotNull("gitlabCommitTitle", commitTitle);
variables.putIfNotNull("gitlabCommitAuthorName", commitAuthorName);
variables.putIfNotNull("gitlabCommitAuthorEmail", commitAuthorEmail);
variables.putIfNotNull("gitlabCommitUrl", commitUrl);
variables.putIfNotNull("gitlabProjectWebUrl", projectWebUrl);
variables.putIfNotNull("gitlabProjectPathWithNamespace", projectPathWithNamespace);
return variables;
}
@Exported
public Integer getSourceProjectId() {
return sourceProjectId;
}
@Exported
public Integer getTargetProjectId() {
return targetProjectId;
}
@Exported
public String getBranch() {
return branch;
}
@Exported
public String getSourceBranch() {
return sourceBranch;
}
@Exported
public ActionType getActionType() {
return actionType;
}
@Exported
public String getUserName() {
return userName;
}
@Exported
public String getUserUsername() {
return userUsername;
}
@Exported
public String getUserEmail() {
return userEmail;
}
@Exported
public String getSourceRepoHomepage() {
return sourceRepoHomepage;
}
@Exported
public String getSourceRepoName() {
return sourceRepoName;
}
@Exported
public String getSourceNamespace() {
return sourceNamespace;
}
@Exported
public String getSourceRepoUrl() {
return sourceRepoUrl;
}
@Exported
public String getSourceRepoSshUrl() {
return sourceRepoSshUrl;
}
@Exported
public String getSourceRepoHttpUrl() {
return sourceRepoHttpUrl;
}
@Exported
public String getMergeRequestTitle() {
return mergeRequestTitle;
}
@Exported
public String getMergeCommitSha() {
return mergeCommitSha;
}
@Exported
public String getMergeRequestDescription() {
return mergeRequestDescription;
}
@Exported
public Integer getMergeRequestId() {
return mergeRequestId;
}
@Exported
public Integer getMergeRequestIid() {
return mergeRequestIid;
}
@Exported
public Integer getMergeRequestTargetProjectId() {
return mergeRequestTargetProjectId;
}
@Exported
public List<String> getMergeRequestLabels() {
return mergeRequestLabels;
}
@Exported
public String getTargetBranch() {
return targetBranch;
}
@Exported
public String getTargetRepoName() {
return targetRepoName;
}
@Exported
public String getTargetNamespace() {
return targetNamespace;
}
@Exported
public String getTargetRepoSshUrl() {
return targetRepoSshUrl;
}
@Exported
public String getTargetRepoHttpUrl() {
return targetRepoHttpUrl;
}
@Exported
public String getTriggeredByUser() {
return triggeredByUser;
}
@Exported
public String getBefore() {
return before;
}
@Exported
public String getAfter() {
return after;
}
@Exported
public String getLastCommit() {
return lastCommit;
}
@Exported
public String getTargetProjectUrl() {
return targetProjectUrl;
}
@Exported
public String getRef() {
return ref;
}
@Exported
public String getIsTag() {
return isTag;
}
@Exported
public String getSha() {
return sha;
}
@Exported
public String getBeforeSha() {
return beforeSha;
}
@Exported
public String getStatus() {
return status;
}
@Exported
public String getStages() {
return stages;
}
@Exported
public String getCreatedAt() {
return createdAt;
}
@Exported
public String getFinishedAt() {
return finishedAt;
}
@Exported
public String getBuildDuration() {
return buildDuration;
}
@Exported
public String getCommentAuthor() {
return commentAuthor;
}
@Exported
public Integer getPipelineId() {
return pipelineId;
}
@Exported
public Integer getPipelineIid() {
return pipelineIid;
}
@Exported
public String getPipelineSource() {
return pipelineSource;
}
@Exported
public String getPipelineUrl() {
return pipelineUrl;
}
@Exported
public String getCommitMessage() {
return commitMessage;
}
@Exported
public String getCommitTitle() {
return commitTitle;
}
@Exported
public String getCommitAuthorName() {
return commitAuthorName;
}
@Exported
public String getCommitAuthorEmail() {
return commitAuthorEmail;
}
@Exported
public String getCommitUrl() {
return commitUrl;
}
@Exported
public String getProjectWebUrl() {
return projectWebUrl;
}
@Exported
public String getProjectPathWithNamespace() {
return projectPathWithNamespace;
}
String getShortDescription() {
return actionType.getShortDescription(this);
}
@Exported
public String getMergeRequestState() {
return mergeRequestState;
}
@Exported
public String getMergedByUser() {
return mergedByUser;
}
@Exported
public String getMergeRequestAssignee() {
return mergeRequestAssignee;
}
@Exported
public MergeRequest getMergeRequest() {
if (mergeRequestId == null) {
return null;
}
return new MergeRequest(
mergeRequestId,
mergeRequestIid,
mergeCommitSha,
sourceBranch,
targetBranch,
mergeRequestTitle,
sourceProjectId,
targetProjectId,
mergeRequestDescription,
mergeRequestState);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CauseData causeData = (CauseData) o;
return new EqualsBuilder()
.append(actionType, causeData.actionType)
.append(sourceProjectId, causeData.sourceProjectId)
.append(targetProjectId, causeData.targetProjectId)
.append(branch, causeData.branch)
.append(sourceBranch, causeData.sourceBranch)
.append(userName, causeData.userName)
.append(userUsername, causeData.userUsername)
.append(userEmail, causeData.userEmail)
.append(sourceRepoHomepage, causeData.sourceRepoHomepage)
.append(sourceRepoName, causeData.sourceRepoName)
.append(sourceNamespace, causeData.sourceNamespace)
.append(sourceRepoUrl, causeData.sourceRepoUrl)
.append(sourceRepoSshUrl, causeData.sourceRepoSshUrl)
.append(sourceRepoHttpUrl, causeData.sourceRepoHttpUrl)
.append(mergeCommitSha, causeData.mergeCommitSha)
.append(mergeRequestTitle, causeData.mergeRequestTitle)
.append(mergeRequestDescription, causeData.mergeRequestDescription)
.append(mergeRequestId, causeData.mergeRequestId)
.append(mergeRequestIid, causeData.mergeRequestIid)
.append(mergeRequestState, causeData.mergeRequestState)
.append(mergedByUser, causeData.mergedByUser)
.append(mergeRequestAssignee, causeData.mergeRequestAssignee)
.append(mergeRequestTargetProjectId, causeData.mergeRequestTargetProjectId)
.append(mergeRequestLabels, causeData.mergeRequestLabels)
.append(targetBranch, causeData.targetBranch)
.append(targetRepoName, causeData.targetRepoName)
.append(targetNamespace, causeData.targetNamespace)
.append(targetRepoSshUrl, causeData.targetRepoSshUrl)
.append(targetRepoHttpUrl, causeData.targetRepoHttpUrl)
.append(triggeredByUser, causeData.triggeredByUser)
.append(before, causeData.before)
.append(after, causeData.after)
.append(lastCommit, causeData.lastCommit)
.append(targetProjectUrl, causeData.targetProjectUrl)
.append(ref, causeData.getRef())
.append(isTag, causeData.getIsTag())
.append(sha, causeData.getSha())
.append(beforeSha, causeData.getBeforeSha())
.append(status, causeData.getStatus())
.append(stages, causeData.getStages())
.append(createdAt, causeData.getCreatedAt())
.append(finishedAt, causeData.getFinishedAt())
.append(buildDuration, causeData.getBuildDuration())
.append(commentAuthor, causeData.getCommentAuthor())
.append(pipelineId, causeData.getPipelineId())
.append(pipelineIid, causeData.getPipelineIid())
.append(pipelineSource, causeData.getPipelineSource())
.append(pipelineUrl, causeData.getPipelineUrl())
.append(commitMessage, causeData.getCommitMessage())
.append(commitTitle, causeData.getCommitTitle())
.append(commitAuthorName, causeData.getCommitAuthorName())
.append(commitAuthorEmail, causeData.getCommitAuthorEmail())
.append(commitUrl, causeData.getCommitUrl())
.append(projectWebUrl, causeData.getProjectWebUrl())
.append(projectPathWithNamespace, causeData.getProjectPathWithNamespace())
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(actionType)
.append(sourceProjectId)
.append(targetProjectId)
.append(branch)
.append(sourceBranch)
.append(userName)
.append(userUsername)
.append(userEmail)
.append(sourceRepoHomepage)
.append(sourceRepoName)
.append(sourceNamespace)
.append(sourceRepoUrl)
.append(sourceRepoSshUrl)
.append(sourceRepoHttpUrl)
.append(mergeCommitSha)
.append(mergeRequestTitle)
.append(mergeRequestDescription)
.append(mergeRequestId)
.append(mergeRequestIid)
.append(mergeRequestState)
.append(mergedByUser)
.append(mergeRequestAssignee)
.append(mergeRequestTargetProjectId)
.append(mergeRequestLabels)
.append(targetBranch)
.append(targetRepoName)
.append(targetNamespace)
.append(targetRepoSshUrl)
.append(targetRepoHttpUrl)
.append(triggeredByUser)
.append(before)
.append(after)
.append(lastCommit)
.append(targetProjectUrl)
.append(ref)
.append(isTag)
.append(sha)
.append(beforeSha)
.append(status)
.append(stages)
.append(createdAt)
.append(finishedAt)
.append(buildDuration)
.append(commentAuthor)
.append(pipelineId)
.append(pipelineIid)
.append(pipelineSource)
.append(pipelineUrl)
.append(commitMessage)
.append(commitTitle)
.append(commitAuthorName)
.append(commitAuthorEmail)
.append(commitUrl)
.append(projectWebUrl)
.append(projectPathWithNamespace)
.toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("actionType", actionType)
.append("sourceProjectId", sourceProjectId)
.append("targetProjectId", targetProjectId)
.append("branch", branch)
.append("sourceBranch", sourceBranch)
.append("userName", userName)
.append("userUsername", userUsername)
.append("userEmail", userEmail)
.append("sourceRepoHomepage", sourceRepoHomepage)
.append("sourceRepoName", sourceRepoName)
.append("sourceNamespace", sourceNamespace)
.append("sourceRepoUrl", sourceRepoUrl)
.append("sourceRepoSshUrl", sourceRepoSshUrl)
.append("sourceRepoHttpUrl", sourceRepoHttpUrl)
.append("mergeCommitSha", mergeCommitSha)
.append("mergeRequestTitle", mergeRequestTitle)
.append("mergeRequestDescription", mergeRequestDescription)
.append("mergeRequestId", mergeRequestId)
.append("mergeRequestIid", mergeRequestIid)
.append("mergeRequestState", mergeRequestState)
.append("mergedByUser", mergedByUser)
.append("mergeRequestAssignee", mergeRequestAssignee)
.append("mergeRequestTargetProjectId", mergeRequestTargetProjectId)
.append("mergeRequestLabels", mergeRequestLabels)
.append("targetBranch", targetBranch)
.append("targetRepoName", targetRepoName)
.append("targetNamespace", targetNamespace)
.append("targetRepoSshUrl", targetRepoSshUrl)
.append("targetRepoHttpUrl", targetRepoHttpUrl)
.append("triggeredByUser", triggeredByUser)
.append("before", before)
.append("after", after)
.append("lastCommit", lastCommit)
.append("targetProjectUrl", targetProjectUrl)
.append("ref", ref)
.append("isTag", isTag)
.append("sha", sha)
.append("beforeSha", beforeSha)
.append("status", status)
.append("stages", stages)
.append("createdAt", createdAt)
.append("finishedAt", finishedAt)
.append("duration", buildDuration)
.append("commentAuthor", commentAuthor)
.append("pipelineId", pipelineId)
.append("pipelineIid", pipelineIid)
.append("pipelineSource", pipelineSource)
.append("pipelineUrl", pipelineUrl)
.append("commitMessage", commitMessage)
.append("commitTitle", commitTitle)
.append("commitAuthorName", commitAuthorName)
.append("commitAuthorEmail", commitAuthorEmail)
.append("commitUrl", commitUrl)
.append("projectWebUrl", projectWebUrl)
.append("projectPathWithNamespace", projectPathWithNamespace)
.toString();
}
public enum ActionType {
PUSH {
@Override
String getShortDescription(CauseData data) {
return getShortDescriptionPush(data);
}
},
TAG_PUSH {
@Override
String getShortDescription(CauseData data) {
return getShortDescriptionPush(data);
}
},
MERGE {
@Override
String getShortDescription(CauseData data) {
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch())
? ""
: data.getSourceNamespace() + "/";
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter
|| data.getTargetProjectUrl() == null) {
return Messages.GitLabWebHookCause_ShortDescription_MergeRequestHook_plain(
String.valueOf(data.getMergeRequestIid()),
forkNamespace + data.getSourceBranch(),
data.getTargetBranch());
} else {
return Messages.GitLabWebHookCause_ShortDescription_MergeRequestHook_html(
String.valueOf(data.getMergeRequestIid()),
forkNamespace + data.getSourceBranch(),
data.getTargetBranch(),
data.getTargetProjectUrl());
}
}
},
NOTE {
@Override
String getShortDescription(CauseData data) {
String triggeredBy = data.getTriggeredByUser();
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch())
? ""
: data.getSourceNamespace() + "/";
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter
|| data.getTargetProjectUrl() == null) {
return Messages.GitLabWebHookCause_ShortDescription_NoteHook_plain(
triggeredBy,
String.valueOf(data.getMergeRequestIid()),
forkNamespace + data.getSourceBranch(),
data.getTargetBranch());
} else {
return Messages.GitLabWebHookCause_ShortDescription_NoteHook_html(
triggeredBy,
String.valueOf(data.getMergeRequestIid()),
forkNamespace + data.getSourceBranch(),
data.getTargetBranch(),
data.getTargetProjectUrl());
}
}
},
PIPELINE {
@Override
String getShortDescription(CauseData data) {
String getStatus = data.getStatus();
if (getStatus == null) {
return Messages.GitLabWebHookCause_ShortDescription_PipelineHook_noStatus();
} else {
return Messages.GitLabWebHookCause_ShortDescription_PipelineHook(getStatus);
}
}
};
private static String getShortDescriptionPush(CauseData data) {
String pushedBy = data.getTriggeredByUser();
if (pushedBy == null) {
return Messages.GitLabWebHookCause_ShortDescription_PushHook_noUser();
} else {
return Messages.GitLabWebHookCause_ShortDescription_PushHook(pushedBy);
}
}
abstract String getShortDescription(CauseData data);
}
private static class MapWrapper<K, V> extends AbstractMap<K, V> {
private final Map<K, V> map;
MapWrapper(Map<K, V> map) {
this.map = map;
}
@Override
public V put(K key, V value) {
return map.put(key, value);
}
@Override
public Set<Entry<K, V>> entrySet() {
return map.entrySet();
}
void putIfNotNull(K key, V value) {
if (value != null) {
map.put(key, value);
}
}
}
}