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

Cannot populate servers via groovy script

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Centos 7.2
      java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2
      jenkins-2.19.2-1.1
      Active Directory plugin 2.0
    • Similar Issues:

      Description

      Using groovy script like this:

      import jenkins.model.*
      import hudson.security.*
      import hudson.plugins.active_directory.*

      def instance = Jenkins.getInstance()
      String domain = 'mydomain.com'
      String site = null
      String server = 'my_ldap_server'
      String bindName = null
      String bindPassword = null

      adrealm = new ActiveDirectorySecurityRealm(domain, site, bindName, bindPassword, server)
      instance.setSecurityRealm(adrealm)

      instance.save()

      field domain controllers remains empty. This was working in previous version of plugin and it's somehow related to multiple domain support.

        Attachments

          Activity

          Hide
          fbelzunc Félix Belzunce Arcos added a comment -

          Thanks for submitting this bug.

          I am reducing the priority to Minor since using the latest constructor should work. What is failing is the backward compatibility

              public ActiveDirectorySecurityRealm(String domain, List<ActiveDirectoryDomain> domains, String site, String bindName,
                                                  String bindPassword, String server, GroupLookupStrategy groupLookupStrategy, boolean removeIrrelevantGroups, Boolean customDomain, CacheConfiguration cache) {
          
          Show
          fbelzunc Félix Belzunce Arcos added a comment - Thanks for submitting this bug. I am reducing the priority to Minor since using the latest constructor should work. What is failing is the backward compatibility public ActiveDirectorySecurityRealm( String domain, List<ActiveDirectoryDomain> domains, String site, String bindName, String bindPassword, String server, GroupLookupStrategy groupLookupStrategy, boolean removeIrrelevantGroups, Boolean customDomain, CacheConfiguration cache) {
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Félix Belzunce Arcos
          Path:
          src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java
          http://jenkins-ci.org/commit/active-directory-plugin/fdb51d74512b4a4b97d11a56857fbf05a3a89fd8
          Log:
          [FIXED JENKINS-39676] Cannot populate servers via groovy script

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Félix Belzunce Arcos Path: src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java http://jenkins-ci.org/commit/active-directory-plugin/fdb51d74512b4a4b97d11a56857fbf05a3a89fd8 Log: [FIXED JENKINS-39676] Cannot populate servers via groovy script
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Felix Belzunce Arcos
          Path:
          src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java
          http://jenkins-ci.org/commit/active-directory-plugin/67186c85e27f077a745f0e9df21d488f57a63037
          Log:
          Merge pull request #55 from fbelzunc/JENKINS-39676

          [FIXED JENKINS-39676] Cannot populate servers via groovy script

          Compare: https://github.com/jenkinsci/active-directory-plugin/compare/8675b696e46b...67186c85e27f

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Felix Belzunce Arcos Path: src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java http://jenkins-ci.org/commit/active-directory-plugin/67186c85e27f077a745f0e9df21d488f57a63037 Log: Merge pull request #55 from fbelzunc/ JENKINS-39676 [FIXED JENKINS-39676] Cannot populate servers via groovy script Compare: https://github.com/jenkinsci/active-directory-plugin/compare/8675b696e46b...67186c85e27f
          Hide
          fbelzunc Félix Belzunce Arcos added a comment -

          Meanwhile this is not released, please migrate to the new Descriptor.

              @DataBoundConstructor
              // as Java signature, this binding doesn't make sense, so please don't use this constructor
              public ActiveDirectorySecurityRealm(String domain, List<ActiveDirectoryDomain> domains, String site, String bindName,
                                                  String bindPassword, String server, GroupLookupStrategy groupLookupStrategy, boolean removeIrrelevantGroups, Boolean customDomain, CacheConfiguration cache) {
          
          import hudson.plugins.active_directory.* 
          import jenkins.model.*
          
          def instance = Jenkins.getInstance();
          def ActiveDirectoryDomain adDomain = new ActiveDirectoryDomain("Example_Domain_Name_2", "Example_Domain_Controller_2");
          def domains = new ArrayList<ActiveDirectoryDomain>();
          domains.add(adDomain);
          
          def securityRealm = new ActiveDirectorySecurityRealm( 
          "", 
          domains,
          "", 
          "",
          "",  
          "", 
          GroupLookupStrategy.RECURSIVE,
          false,
          true,
          null)
          println(securityRealm.domains)
          
          instance.setSecurityRealm(securityRealm) 
          instance.save()
          
          Show
          fbelzunc Félix Belzunce Arcos added a comment - Meanwhile this is not released, please migrate to the new Descriptor. @DataBoundConstructor // as Java signature, this binding doesn 't make sense, so please don' t use this constructor public ActiveDirectorySecurityRealm( String domain, List<ActiveDirectoryDomain> domains, String site, String bindName, String bindPassword, String server, GroupLookupStrategy groupLookupStrategy, boolean removeIrrelevantGroups, Boolean customDomain, CacheConfiguration cache) { import hudson.plugins.active_directory.* import jenkins.model.* def instance = Jenkins.getInstance(); def ActiveDirectoryDomain adDomain = new ActiveDirectoryDomain( "Example_Domain_Name_2" , "Example_Domain_Controller_2" ); def domains = new ArrayList<ActiveDirectoryDomain>(); domains.add(adDomain); def securityRealm = new ActiveDirectorySecurityRealm( "", domains, "", "", "", "", GroupLookupStrategy.RECURSIVE, false , true , null ) println(securityRealm.domains) instance.setSecurityRealm(securityRealm) instance.save()

            People

            • Assignee:
              fbelzunc Félix Belzunce Arcos
              Reporter:
              smaj Sebastian Maj
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: