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

Configure AD Authorization with Groovy

XMLWordPrintable

      I am working on configuring Active Directory via Groovy.

      I was able to authenticate via active directory via the UI.

      I have the following based on the LDAP plugin:

          import jenkins.model.*
          import hudson.security.*
          import hudson.plugins.*
          import hudson.plugins.active_directory.*
          import hudson.*
          import jenkins.*
      
          String domain = 'my.domain.com'
          String site = ''
          String server = '192.168.1.1'
          String bindName = 'account@my.domain.com'
          String bindPassword = 'password'
      
          SecurityRealm ad_realm = new ActiveDirectorySecurityRealm(domain, site, bindName, bindPassword, server)
          jenkins.instance.setSecurityRealm(ad_realm)
      

      This is the error:

      Expected process to exit with [0], but received '255'
                 ---- Begin output of "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 ----
                 STDOUT: 
                 STDERR: groovy.lang.MissingPropertyException: No such property: jenkins for class: RemoteClass
                 	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
                 	at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
                 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
                 	at RemoteClass.run(RemoteClass:16)
                 	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:266)
                 	at groovy.lang.GroovyShell.run(GroovyShell.java:517)
                 	at hudson.cli.GroovyCommand.run(GroovyCommand.java:86)
                 	at hudson.cli.CLICommand.main(CLICommand.java:237)
                 	at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:92)
                 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 	at java.lang.reflect.Method.invoke(Method.java:497)
                 	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:608)
                 	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:583)
                 	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:542)
                 	at hudson.remoting.UserRequest.perform(UserRequest.java:120)
                 	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
                 	at hudson.remoting.Request$2.run(Request.java:326)
                 	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
                 	at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:63)
                 	at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
                 	at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
                 	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
                 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                 	at java.lang.Thread.run(Thread.java:745)
                 ---- End output of "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 ----
                 Ran "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 returned 255
      

      Any idea on why I see No such property: jenkins for class: RemoteClass?

            Unassigned Unassigned
            jsmickey John Mickey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: