[JIRA] (JENKINS-57880) Check if gitlab server name is unique

14 views
Skip to first unread message

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:50:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda created an issue
 
Jenkins / Bug JENKINS-57880
Check if gitlab server name is unique
Issue Type: Bug Bug
Assignee: Parichay Barpanda
Components: gitlab-branch-source-plugin
Created: 2019-06-06 11:49
Labels: gsoc-2019
Priority: Minor Minor
Reporter: Parichay Barpanda

The plugin will filter the gitlab servers based on unique names. I want to add a field in the GitLabServer DescriptorImpl to send a warning at runtime to enter a unqiue name. But descriptorImpl is static so I haven't been about to figure out how to check if the rest of the servers defined have a different name. Also since DescriptorImpl is in static context, so error is displayed across all fields with non-unique name.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:52:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda updated an issue
Change By: Parichay Barpanda
The plugin will filter the gitlab servers based on unique names. I want to add a field in the GitLabServer DescriptorImpl to send a warning at runtime to enter a unqiue name. But descriptorImpl is static so I haven't been about to figure out how to check if the rest of the servers defined have a different name. Also since Since DescriptorImpl is in static context, so error the field is displayed across all fields compare with non-unique name the it's own server object as well and raises an formvalidation error by default .

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:54:01 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda commented on Bug JENKINS-57880
 
Re: Check if gitlab server name is unique

The part of code that I am trying to add to GitLabServer descriptorImp:

/** Checks that the name given to server is unique
*

  • @param name the name given to server
  • @return the validation results.
    */
    public static FormValidation doCheckName(@QueryParameter String name) {
    List<GitLabServer> serverList = GitLabServers.get().getServers();
    for(GitLabServer server : serverList)
    Unknown macro: { if(name.equals(server.getName())) { return FormValidation.error("Please enter a unique server name"); } }

    return FormValidation.ok();
    }

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:54:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda updated an issue
Change By: Parichay Barpanda
Attachment: Screenshot from 2019-06-06 17-21-50.png

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:55:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda edited a comment on Bug JENKINS-57880
The part of code that I am trying to add to GitLabServer descriptorImp:

/** Checks that the name given to server is unique
         *
         * @param name the name given to server
         * @return the validation results.
         */
        public static FormValidation doCheckName(@QueryParameter String name) {
            List<GitLabServer> serverList = GitLabServers.get().getServers();
            for(GitLabServer server : serverList) {

                if(name.equals(server.getName())) {
                    return FormValidation.error("Please enter a unique server name");
                }
            }
            return FormValidation.ok();
        }

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:56:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda edited a comment on Bug JENKINS-57880
The part of code that I am trying to add to GitLabServer descriptorImp:

public static FormValidation doCheckName(@QueryParameter String name) {
   List<GitLabServer> serverList = GitLabServers.get().getServers();
   for(GitLabServer server : serverList) {
     if(name.equals(server.getName())) {
       return FormValidation.error("Please enter a unique server name");
     }
   }
   return FormValidation.ok();
}

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 7:58:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda edited a comment on Bug JENKINS-57880
The part of code that I am trying to add to GitLabServer descriptorImp descriptorImpl :
{code:java}
/** Checks that the name given to server is unique
*
* @param name the name given to server
* @return the validation results.
*/
public static FormValidation doCheckName(@QueryParameter String name) {
     List<GitLabServer> serverList = GitLabServers.get().getServers();
     for(GitLabServer server : serverList) {
         if(name.equals(server.getName())) {
              return FormValidation.error("Please enter a unique server name");
         }
     }
     return FormValidation.ok();
}

{code}


parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 9:17:01 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda started work on Bug JENKINS-57880
 
Change By: Parichay Barpanda
Status: Open In Progress

parichay.barpanda@gmail.com (JIRA)

unread,
Jun 6, 2019, 9:40:02 AM6/6/19
to jenkinsc...@googlegroups.com
Parichay Barpanda closed an issue as Fixed
 

This issue has been resolved by adding a default unique value to GitLabServer expecting that user doesn't change it. See https://github.com/baymac/gitlab-branch-source-plugin/pull/5

Change By: Parichay Barpanda
Status: In Progress Closed
Resolution: Fixed
Reply all
Reply to author
Forward
0 new messages