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

RejectedAccessException: unclassified method org.jfrog.hudson.pipeline.types.Docker withRegistry

      If i user this pipeline code:

      def server = Artifactory.server('artifactory_global')
      def rtDocker = Artifactory.docker()

      node {
      docker.withRegistry("http://${registry}", "admnexus" ) {
      }
      }

      I get this error:

      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method org.jfrog.hudson.pipeline.types.Docker withRegistry org.codehaus.groovy.runtime.GStringImpl java.lang.String org.jenkinsci.plugins.workflow.cps.CpsClosure2
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      at WorkflowScript.run(WorkflowScript:24)
      at __cps.transform__(Native Method)
      at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      at sun.reflect.GeneratedMethodAccessor178.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
      at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      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)

          [JENKINS-39814] RejectedAccessException: unclassified method org.jfrog.hudson.pipeline.types.Docker withRegistry

          Thanks for reporting this issue, we were unable to reproduce this issue with the provided pipeline script.
          Could you provide a full pipeline script example that causes this issue?

          Roman Gurevitch added a comment - Thanks for reporting this issue, we were unable to reproduce this issue with the provided pipeline script. Could you provide a full pipeline script example that causes this issue?

          node {
          stage("test") {
          def server = Artifactory.server('artifactory_global')
          def rtDocker = Artifactory.docker()
          rtDocker.withRegistry("https://maregistry/", "admnexus" )

          { rtDocker.pull("maregistry/library/hello-world") rtDocker.push("maregistry/library/hello-world", "maregistry/library/hello-world") }

          }
          }

          sébastien glon added a comment - node { stage("test") { def server = Artifactory.server('artifactory_global') def rtDocker = Artifactory.docker() rtDocker.withRegistry("https://maregistry/", "admnexus" ) { rtDocker.pull("maregistry/library/hello-world") rtDocker.push("maregistry/library/hello-world", "maregistry/library/hello-world") } } }

          There is a difference between the global variable docker and the defined variable rtDocker which is part of Artifactory jenkins plugin.
          The correct usage in this instance is docker.withRegistry not rtDocker.withRegistry.

          Please note that using docker.withRegistry is not designed to work with Artifactory.docker API.
          Pushing image with Artifactory plugin require setting username and password or credentialsId for Artifactory docker instance and pushing the correct tagged image that includes the registry path, for example:
          def rtDocker = Artifactory.docker credentialsId: "credentialsPluginId"
          rtDocker.push("registry/imageName:version", "targetRepositoryNameInArtifactory")

          More information can be found in the following link: https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin

          Roman Gurevitch added a comment - There is a difference between the global variable docker and the defined variable rtDocker which is part of Artifactory jenkins plugin. The correct usage in this instance is docker.withRegistry not rtDocker.withRegistry. Please note that using docker.withRegistry is not designed to work with Artifactory.docker API. Pushing image with Artifactory plugin require setting username and password or credentialsId for Artifactory docker instance and pushing the correct tagged image that includes the registry path, for example: def rtDocker = Artifactory.docker credentialsId: "credentialsPluginId" rtDocker.push("registry/imageName:version", "targetRepositoryNameInArtifactory") More information can be found in the following link: https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin

          sébastien glon added a comment - - edited

          Is it possible to use credentialID and not hardCoded Login Password?

          On server global config, i have defined default credential but i always have an "unauthorized: authentication required' but this is the same user/password that i use on docker.push

          sébastien glon added a comment - - edited Is it possible to use credentialID and not hardCoded Login Password? On server global config, i have defined default credential but i always have an "unauthorized: authentication required' but this is the same user/password that i use on docker.push

          Yes, our latest plugin version 2.8.1 supports credentials plugin.
          Example can be found in the previous message and in our documentation.
          Please contact our support for further configuration issues at: https://support.jfrog.com/

          Roman Gurevitch added a comment - Yes, our latest plugin version 2.8.1 supports credentials plugin. Example can be found in the previous message and in our documentation. Please contact our support for further configuration issues at: https://support.jfrog.com/

            eyalbe Eyal Ben Moshe
            sebglon sébastien glon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: