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

Unable to resolve class jenkins.security.apitoken.ApiTokenStore.TokenUuidAndPlainValue

XMLWordPrintable

      The class `jenkins.security.apitoken.ApiTokenStore.TokenUuidAndPlainValue` can no longer be loaded.

      This issue appears when trying to use this class in a start up groovy script under "/usr/share/jenkins/ref/". The Groovy script is something like this

       

      import jenkins.security.apitoken.ApiTokenStore
      import jenkins.security.ApiTokenProperty
      
      Thread.start {
          while (Jenkins.instance.initLevel != COMPLETED) {
              println('waiting for Jenkins to be fully up before provisioning API users')
              sleep 1000
          }
          def username = "some user"
          def tokenName = 'some name'
          User u = User.get(username)
      
          ApiTokenProperty p = u.getProperty(ApiTokenProperty.class)
          if (p == null) {
              p = forceNewInstance(u, false);
              u.addProperty(p);
          }
          ApiTokenStore.TokenUuidAndPlainValue tokenUuidAndPlainValue = p.tokenStore.generateNewToken(tokenName);
      }
      

      An Exception with the  message: unable to resolve class ApiTokenStore.TokenUuidAndPlainValue is thrown when this script is executed

            Unassigned Unassigned
            nashwan Nashwan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: