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

Referenced parameters not passed to groovy script for reactive reference

      Groovy script works in the script console but not in the Active Choices Reactive Reference Parameter.

      Log for the plugin gives:

      groovy.lang.MissingPropertyException: No such property: VSIM_PROJ for class: Script1

      Referenced Parameters: VSIM_PROJ,VSIM_BUILD

      groovy script:

      import jenkins.model.Jenkins
      import hudson.model.AbstractProject
      import hudson.model.Result
      import hudson.util.RunList
      
      AbstractProject<?, ?> otherJob = Jenkins.getInstance().getItemByFullName(VSIM_PROJ, AbstractProject.class)
      
      def otherBuild = otherJob.getBuildByNumber(VSIM_BUILD)
      def dispName = otherBuild.displayName
      
      return "${dispName }"
      

          [JENKINS-37935] Referenced parameters not passed to groovy script for reactive reference

          I would not trust the log output as currently it is 'contaminated' with several such messages even when things work. I would pay more attention to returning valid HTML when an AC-reactive reference is used. Also, use the fallback script option so that you at least get a better idea that the script works in the AC context.

          Finally use logic like:

          if (binding.variables.containsKey("VSIM_PROJ")){
          //do things when the VSIM_PROJ var is in the script binding
          }else{
          //or else...
          }
          
          

          Ioannis Moutsatsos added a comment - I would not trust the log output as currently it is 'contaminated' with several such messages even when things work. I would pay more attention to returning valid HTML when an AC-reactive reference is used. Also, use the fallback script option so that you at least get a better idea that the script works in the AC context. Finally use logic like: if (binding.variables.containsKey( "VSIM_PROJ" )){ // do things when the VSIM_PROJ var is in the script binding } else { //or else ... }

          What parameter type is VSIM_PROJ? The code is really useful for debugging this issue, but before trying it locally, it would be necessary to know the parameter type.

          And +1 for Ioannis's comment as well. We are working to have a better logging output, but in the meantime stick with the fallback script, and write your scripts defensively

          Bruno P. Kinoshita added a comment - What parameter type is VSIM_PROJ? The code is really useful for debugging this issue, but before trying it locally, it would be necessary to know the parameter type. And +1 for Ioannis's comment as well. We are working to have a better logging output, but in the meantime stick with the fallback script, and write your scripts defensively

          Hi, closing as Cannot Reproduce. In case the problem persists, with the latest version of the plug-in and its matching Jenkins LTS version, feel free to re-open or file a new issue, providing config.xml, or script examples, screen shots, and any other artefact that may be helpful for developers to reproduce the problem.

          Thank you!
          Bruno

          Bruno P. Kinoshita added a comment - Hi, closing as Cannot Reproduce. In case the problem persists, with the latest version of the plug-in and its matching Jenkins LTS version, feel free to re-open or file a new issue, providing config.xml, or script examples, screen shots, and any other artefact that may be helpful for developers to reproduce the problem. Thank you! Bruno

            kinow Bruno P. Kinoshita
            grush128 Jason Grosch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: