@@ -96,12 +96,42 @@ public GitLabPushTrigger(boolean triggerOnPush, boolean triggerOnMergeRequest, T
96
96
initializeBranchFilter ();
97
97
}
98
98
99
+ @ Initializer (after = InitMilestone .JOB_LOADED )
100
+ public static void migrateJobs () throws IOException {
101
+ GitLabPushTrigger .DescriptorImpl oldConfig = Trigger .all ().get (GitLabPushTrigger .DescriptorImpl .class );
102
+ if (!oldConfig .jobsMigrated ) {
103
+ GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig ) Jenkins .getInstance ().getDescriptor (GitLabConnectionConfig .class );
104
+ gitLabConfig .getConnections ().add (new GitLabConnection (oldConfig .gitlabHostUrl ,
105
+ oldConfig .gitlabHostUrl ,
106
+ oldConfig .gitlabApiToken ,
107
+ oldConfig .ignoreCertificateErrors ));
108
+
109
+ String defaultConnectionName = gitLabConfig .getConnections ().get (0 ).getName ();
110
+ for (AbstractProject <?, ?> project : Jenkins .getInstance ().getAllItems (AbstractProject .class )) {
111
+ GitLabPushTrigger trigger = project .getTrigger (GitLabPushTrigger .class );
112
+ if (trigger != null ) {
113
+ if (trigger .addCiMessage ) {
114
+ project .getPublishersList ().add (new GitLabCommitStatusPublisher ());
115
+ }
116
+ if (trigger .branchFilterType == null ) {
117
+ trigger .branchFilterType = trigger .branchFilterName ;
118
+ }
119
+ project .addProperty (new GitLabConnectionProperty (defaultConnectionName ));
120
+ project .save ();
121
+ }
122
+ }
123
+ gitLabConfig .save ();
124
+ oldConfig .jobsMigrated = true ;
125
+ oldConfig .save ();
126
+ }
127
+ }
128
+
99
129
public boolean getTriggerOnPush () {
100
- return triggerOnPush ;
130
+ return triggerOnPush ;
101
131
}
102
132
103
133
public boolean getTriggerOnMergeRequest () {
104
- return triggerOnMergeRequest ;
134
+ return triggerOnMergeRequest ;
105
135
}
106
136
107
137
public TriggerOpenMergeRequest getTriggerOpenMergeRequestOnPush () {
@@ -177,14 +207,14 @@ protected Object readResolve() throws ObjectStreamException {
177
207
@ Extension
178
208
public static class DescriptorImpl extends TriggerDescriptor {
179
209
210
+ private transient final SequentialExecutionQueue queue = new SequentialExecutionQueue (Jenkins .MasterComputer .threadPoolForRemoting );
180
211
private boolean jobsMigrated = false ;
181
212
private String gitlabApiToken ;
182
213
private String gitlabHostUrl = "" ;
183
214
private boolean ignoreCertificateErrors = false ;
184
- private transient final SequentialExecutionQueue queue = new SequentialExecutionQueue (Jenkins .MasterComputer .threadPoolForRemoting );
185
215
186
216
public DescriptorImpl () {
187
- load ();
217
+ load ();
188
218
}
189
219
190
220
@ Override
@@ -240,9 +270,9 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
240
270
}
241
271
242
272
public ListBoxModel doFillTriggerOpenMergeRequestOnPushItems (@ QueryParameter String triggerOpenMergeRequestOnPush ) {
243
- return new ListBoxModel (new Option ("Never" , "never" , triggerOpenMergeRequestOnPush .matches ("never" ) ),
244
- new Option ("On push to source branch" , "source" , triggerOpenMergeRequestOnPush .matches ("source" ) ),
245
- new Option ("On push to source or target branch" , "both" , triggerOpenMergeRequestOnPush .matches ("both" ) ));
273
+ return new ListBoxModel (new Option ("Never" , "never" , triggerOpenMergeRequestOnPush .matches ("never" )),
274
+ new Option ("On push to source branch" , "source" , triggerOpenMergeRequestOnPush .matches ("source" )),
275
+ new Option ("On push to source or target branch" , "both" , triggerOpenMergeRequestOnPush .matches ("both" )));
246
276
}
247
277
248
278
public AutoCompletionCandidates doAutoCompleteIncludeBranchesSpec (@ AncestorInPath final Job <?, ?> job , @ QueryParameter final String value ) {
@@ -261,34 +291,4 @@ public FormValidation doCheckExcludeBranchesSpec(@AncestorInPath final Job<?, ?>
261
291
return ProjectBranchesProvider .instance ().doCheckBranchesSpec (project , value );
262
292
}
263
293
}
264
-
265
- @ Initializer (after = InitMilestone .JOB_LOADED )
266
- public static void migrateJobs () throws IOException {
267
- GitLabPushTrigger .DescriptorImpl oldConfig = Trigger .all ().get (GitLabPushTrigger .DescriptorImpl .class );
268
- if (!oldConfig .jobsMigrated ) {
269
- GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig ) Jenkins .getInstance ().getDescriptor (GitLabConnectionConfig .class );
270
- gitLabConfig .getConnections ().add (new GitLabConnection (oldConfig .gitlabHostUrl ,
271
- oldConfig .gitlabHostUrl ,
272
- oldConfig .gitlabApiToken ,
273
- oldConfig .ignoreCertificateErrors ));
274
-
275
- String defaultConnectionName = gitLabConfig .getConnections ().get (0 ).getName ();
276
- for (AbstractProject <?, ?> project : Jenkins .getInstance ().getAllItems (AbstractProject .class )) {
277
- GitLabPushTrigger trigger = project .getTrigger (GitLabPushTrigger .class );
278
- if (trigger != null ) {
279
- if (trigger .addCiMessage ) {
280
- project .getPublishersList ().add (new GitLabCommitStatusPublisher ());
281
- }
282
- if (trigger .branchFilterType == null ) {
283
- trigger .branchFilterType = trigger .branchFilterName ;
284
- }
285
- project .addProperty (new GitLabConnectionProperty (defaultConnectionName ));
286
- project .save ();
287
- }
288
- }
289
- gitLabConfig .save ();
290
- oldConfig .jobsMigrated = true ;
291
- oldConfig .save ();
292
- }
293
- }
294
294
}
0 commit comments