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

Active Choice Reactive Parameter not returning list as output

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: active-choices-plugin
    • Labels:
      None
    • Environment:
      jenkins - 2.77
      Active choice plugin - 2.1
      OS - RhEl 6.8
      Webbrowser - Chrome
      Java - 1.8
    • Similar Issues:

      Description

      Hi

       

      I am trying to extract list of version from perforce and return the list , so that developers can select the version from the output listed as radio button/something

      But the return doesnt seem to work , neither does it throw any error

      I have added a print statement and it works fine 

      Printed below  ["1610" ,  "1702" ,  "1703" ,  "1710" ,  "1804" ,  "1806"]

       

      Code 

      ___________________________________________________

      import com.perforce.p4java.server.*
      import com.perforce.p4java.impl.generic.core.file.*
      import groovyx.net.http.RESTClient
      import com.perforce.p4java.core.file.FileSpecBuilder
      import com.perforce.p4java.core.file.FileSpecOpStatus
      import com.perforce.p4java.core.file.IFileSpec
      import com.perforce.p4java.option.server.GetFileContentsOptions

      @Grapes([
      @Grab(group='com.perforce', module='p4java', version='2013.1.656196' ),
      @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )])

      //import com.perforce.p4java.server.*
      //import com.perforce.p4java.impl.generic.core.file.*
      //import groovyx.net.http.RESTClient

      def server = ServerFactory.getServer( "p4java://XXXX:1666", null)
      server.setUserName("username")
      server.connect()
      server.login("password")

      final List<IFileSpec> checkFile = FileSpecBuilder.makeFileSpecList("//depot/Stream_name/Swarm/Stream_Swarm.lst")
      final GetFileContentsOptions gfco = new GetFileContentsOptions()
      gfco.setNoHeaderLine(true)
      gfco.setDontAnnotateFiles(false) // must set this!

      InputStream inStream = server.getFileContents(checkFile, gfco)
      def verlist = []
      inStream.getText("UTF-8").eachLine {
      if (it != null) {
      if (it.contains("${PRODUCT}")){
      String[] tok = it.tokenize("[/\\-]+")
      verlist << tok[1]
      }
      }
      }
      inStream.close()

      def finlstr = verlist.unique().sort().collect{ '"' + it + '"'}.join(",")
      def finl = finlstr.split(',')
      println "$finl"
      try {
      return finl
      }catch(e){ return [e.toString()] }

       

       

        Attachments

        1. 1.JPG
          1.JPG
          94 kB
        2. 2.JPG
          2.JPG
          93 kB
        3. 3.JPG
          3.JPG
          52 kB
        4. 4.JPG
          4.JPG
          21 kB

          Activity

          Hide
          ioannis Ioannis Moutsatsos added a comment -

          def finl = finlstr.split(',')

          This does not return a list in Groovy but a String[]

          try this instead:

          choices=[]

          finl.each

          { choices.add(it) }

          return choices

          Show
          ioannis Ioannis Moutsatsos added a comment - def finl = finlstr.split(',') This does not return a list in Groovy but a String[] try this instead: choices=[] finl.each { choices.add(it) } return choices
          Hide
          ioannis Ioannis Moutsatsos added a comment -

          Closing this as it appears to be a programming issue. The user did not respond to the testing suggestion either

          Show
          ioannis Ioannis Moutsatsos added a comment - Closing this as it appears to be a programming issue. The user did not respond to the testing suggestion either

            People

            • Assignee:
              kinow Bruno P. Kinoshita
              Reporter:
              srava Sravanthi Chadalavada
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: