Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57880

Check if gitlab server name is unique

    XMLWordPrintable

Details

    • GSoC 2019. Coding Phase 1

    Description

      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. Since DescriptorImpl is in static context, the field is compare with the it's own server object as well and raises an formvalidation error by default.

      Attachments

        Activity

          baymac Parichay Barpanda added a comment - - edited

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

          /** 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();
          }
          
          baymac Parichay Barpanda added a comment - - edited The part of code that I am trying to add to GitLabServer descriptorImpl: /** 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(); }

          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

          baymac Parichay Barpanda added a comment - 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

          People

            baymac Parichay Barpanda
            baymac Parichay Barpanda
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: