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

Cannot use groovyscript in freestyle job with plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • active-choices-plugin
    • None
    • Jenkins 2.249.2
      name: uno-choice version: "2.5.1"
      official docker image jenkins/jenkins:lts

      Trying to pull a list of maven artifacts from nexus and I have been stuck on this for a few days and no amount of google searching has helped.
       

      parameters {
         activeChoiceParam('ARTIFACT_VERSION') {
         description('Choose Wisely')
         filterable()
         choiceType('SINGLE_SELECT')
         groovyScript{
           script('''
             def mavendata = new XmlSlurper().parse("''' + jobNexusUrl + '''")
             println mavendata.versioning.versions.version*.text()
             '''
            )
            fallbackScript('"fallback choice"')
          }
        }
      }
      

       
      I get this error when the job is being created by the seedjob.

       

       

      ERROR: (rdrti_app_environment.groovy, line 140) No signature of method: java.lang.String.call() is applicable for argument types: (java.lang.String) values: [ 
      def mavendata = new XmlSlurper().parse("https://nexus.interna.com/nexus/content/repositories/rdrti2-releases/com/rd/rti/rdrti2/maven-metadata.xml")
       println mavendata.versioning.versions.version*.text()
       ]
       Possible solutions: wait(), any(), wait(long), split(java.lang.String), take(int), any(groovy.lang.Closure)
       Finished: FAILURE
      

       
      If i just create a freestyle job in the gui and put in those 2 lines of groovy it works fine

       

       
      Here is a maven metadata example that I tested with
      https://gist.githubusercontent.com/r00t4ccess/14be3e653e8f643e83f3d2ec50b16ef9/raw/afb7a2d5386be58f0ae8057b936bb7514731d2c0/maventest.xml
       
       

       

      def metadata = new XmlSlurper().parse("https://gist.githubusercontent.com/r00t4ccess/14be3e653e8f643e83f3d2ec50b16ef9/raw/afb7a2d5386be58f0ae8057b936bb7514731d2c0/maventest.xml")
      return metadata.versioning.versions.version*.text().reverse()
      

            kinow Bruno P. Kinoshita
            larrycharbonneau Larry Charbonneau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: