4141/**
4242 * Represents a GitLab Server instance.
4343 */
44-
4544public class GitLabServer extends AbstractDescribableImpl <GitLabServer > {
4645
4746 private static final Logger LOGGER = LoggerFactory .getLogger (GitLabServer .class );
@@ -50,6 +49,7 @@ public class GitLabServer extends AbstractDescribableImpl<GitLabServer> {
5049 * Used as default server URL for the serverUrl field
5150 */
5251 public static final String GITLAB_SERVER_URL = "https://gitlab.com" ;
52+
5353 /**
5454 * Used as default token value if no any credentials found by given credentialsId.
5555 */
@@ -220,15 +220,20 @@ public static FormValidation doCheckServerUrl(@QueryParameter String value) {
220220 try {
221221 new URL (value );
222222 } catch (MalformedURLException e ) {
223- LOGGER .error ("Incorrect server url - %s" , value );
224- return FormValidation .error ("Malformed GitLab url (%s)" , e .getMessage ());
223+ LOGGER .error ("Incorrect url - %s" , value );
224+ return FormValidation .error ("Malformed url (%s)" , e .getMessage ());
225225 }
226- // TODO:[JENKINS-57747] Add support for GitLab Ultimate (self hosted) and Gold (saas)
227226 if (GITLAB_SERVER_URL .equals (value )) {
228- LOGGER .info ("Server URL is fine - %s" , value );
227+ LOGGER .info ("Community version of GitLab - %s" , value );
228+ }
229+ GitLabApi gitLabApi = new GitLabApi (value , "" );
230+ try {
231+ gitLabApi .getProjectApi ().getProjects (1 , 1 );
232+ return FormValidation .ok ();
233+ } catch (GitLabApiException e ) {
234+ LOGGER .info ("Unable to validate serverUrl - %s" , value );
235+ return FormValidation .error (Messages .GitLabServer_invalidUrl (value ));
229236 }
230- LOGGER .info ("Unable to validate serverUrl - %s" , value );
231- return FormValidation .ok ();
232237 }
233238
234239 @ NonNull
0 commit comments