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

Reactive Reference Parameter not working with "List Subversion Tags" parameter

    • Icon: Improvement Improvement
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • active-choices-plugin
    • None

      I have a release build job on Jenkins where I extract the major+minor version numbers for the release from the chosen SVN release branch (provided as a "List Subversion Tags" parameter). This extraction is done as a groovy build step (using getTag() of hudson.scm.listtagsparameter.ListSubversionTagsParameterValue and split() of java.lang.String) which injects the major+minor version numbers as variables to build.

      I now tried to provide the major+minor version number as build parameters using Reactive Reference Parameters (with choice type "Input Text Box") that should do this extraction in ther "Script" field of the parameter. Unfortunately I failed. When referring to a "List Subversion Tags" parameter I got an empty string. When returning the class of the referenced "List Subversion Tags" parameter to the text box I see the value "class java.lang.String". However, I would have expected something like "class hudson.scm.listtagsparameter.ListSubversionTagsParameterValue".

      => I am asking for a possibility to retrieve the string value of a "List Subversion Tags" parameter for Reactive Reference Parameters.

          [JENKINS-40501] Reactive Reference Parameter not working with "List Subversion Tags" parameter

          Hi cober, today I do not have time to try to reproduce the issue completely. But maybe a quick reply on this part would help?

          >When returning the class of the referenced "List Subversion Tags" parameter to the text box I see the value "class java.lang.String". However, I would have expected something like "class hudson.scm.listtagsparameter.ListSubversionTagsParameterValue".

          If I understand it correctly, your active choices parameter returned, when executing your Groovy script, value from another parameter as a String, opposed to an object from the Jenkins code base API.

          That would be the expected behaviour. The plug-in works by parsing the HTML DOM. So it has access to only objects in the screen (plus the jenkinsProject variable we inject). So in an active choices parameter, the value returned from other parameters would be a string. And then in your Groovy script for that active choices parameter, you would have to query Jenkins in Groovy, retrieving the item/action/etc, and then populate the current active choices element.

          Hope that helps
          Bruno

          Bruno P. Kinoshita added a comment - Hi cober , today I do not have time to try to reproduce the issue completely. But maybe a quick reply on this part would help? >When returning the class of the referenced "List Subversion Tags" parameter to the text box I see the value "class java.lang.String". However, I would have expected something like "class hudson.scm.listtagsparameter.ListSubversionTagsParameterValue". If I understand it correctly, your active choices parameter returned, when executing your Groovy script, value from another parameter as a String, opposed to an object from the Jenkins code base API. That would be the expected behaviour. The plug-in works by parsing the HTML DOM. So it has access to only objects in the screen (plus the jenkinsProject variable we inject). So in an active choices parameter, the value returned from other parameters would be a string. And then in your Groovy script for that active choices parameter, you would have to query Jenkins in Groovy, retrieving the item/action/etc, and then populate the current active choices element. Hope that helps Bruno

          Closing as Not a Defect cober, as this is working as expected, given the current features of the plug-in.

          From the String value, you will have to use Jenkins API in Groovy and navigate through the objects in Jenkins to reach your ListSubversionTagsParameterValue.

          We are working in the next months to make the Scriptler integration better. So hopefully in the future we will be able to point users with similar issues to existing Scriptler scripts that can, at least, simplify this task.

          Cheers
          Bruno

          Bruno P. Kinoshita added a comment - Closing as Not a Defect cober , as this is working as expected, given the current features of the plug-in. From the String value, you will have to use Jenkins API in Groovy and navigate through the objects in Jenkins to reach your ListSubversionTagsParameterValue. We are working in the next months to make the Scriptler integration better. So hopefully in the future we will be able to point users with similar issues to existing Scriptler scripts that can, at least, simplify this task. Cheers Bruno

          remi P added a comment - - edited

          "When referring to a "List Subversion Tags" parameter I got an empty string."

          That's the defect.

          To reproduce:

          • create a parametrized job
          • use a List Subversion tag parameter named "myTag"
          • try to reference $myTag parameter inside AC Reference Parameter plugin
          • you will get an empty string instead of the tag string value

          Reproduced  with Jenkins 2.138.2,  Subversion plugin 2.12.1 and Active Choice plugin 2.1

          This issue should be reopened.

          remi P added a comment - - edited "When referring to a "List Subversion Tags" parameter I got an empty string." That's the defect. To reproduce: create a parametrized job use a List Subversion tag parameter named "myTag" try to reference $myTag parameter inside AC Reference Parameter plugin you will get an empty string instead of the tag string value Reproduced  with Jenkins 2.138.2,  Subversion plugin 2.12.1 and Active Choice plugin 2.1 This issue should be reopened.

          Sergej Kleva added a comment -

          I do have the same problem!

          Any news about this?

           

          Thanks!

          Sergej Kleva added a comment - I do have the same problem! Any news about this?   Thanks!

          Haven't had time to look into this after rpatriarche's great comment with steps to reproduce. Let's reopen it. If anyone has time to investigate, pull requests welcome!

          Bruno P. Kinoshita added a comment - Haven't had time to look into this after rpatriarche 's great comment with steps to reproduce. Let's reopen it. If anyone has time to investigate, pull requests welcome!

          Hoa Nguyen added a comment -

          Hi was looking into it as I want a solution to this.  I notice that when looking at the Subversion tag parameter field, it is getting the value before the field pulls data from SVN for list of tags.  So probably why it gets an empty string.

          I think if it waited after the load, it would work.

          I'll see if I can play with it.

          Hoa Nguyen added a comment - Hi was looking into it as I want a solution to this.  I notice that when looking at the Subversion tag parameter field, it is getting the value before the field pulls data from SVN for list of tags.  So probably why it gets an empty string. I think if it waited after the load, it would work. I'll see if I can play with it.

          Hoa Nguyen added a comment - - edited

          Hi rpatriarche,

          Not sure if you are interested still, but I opted to not use to reference Jenkins svn tag params(I did not want to mess with JS to fix the loading data issue).  Instead I used the hudson.scm.listtagsparameter.ListSubversionTagsParameterDefinition class.

           

          I used the following groovy script to get the string value.  I referenced a choice parameter that will pass the URL to pull tags from.  Only issue is that I could not get credential ID in scope of my project, only in scope at root level.  Other than that it works!

           

          tag_param = new hudson.scm.listtagsparameter.ListSubversionTagsParameterDefinition('', TAG_URL, 'credential_id_here', '', '', '', false, false)
          tag_param.getTags()
          

          Hoa Nguyen added a comment - - edited Hi rpatriarche , Not sure if you are interested still, but I opted to not use to reference Jenkins svn tag params(I did not want to mess with JS to fix the loading data issue).  Instead I used the hudson.scm.listtagsparameter.ListSubversionTagsParameterDefinition class.   I used the following groovy script to get the string value.  I referenced a choice parameter that will pass the URL to pull tags from.  Only issue is that I could not get credential ID in scope of my project, only in scope at root level.  Other than that it works!   tag_param = new hudson.scm.listtagsparameter.ListSubversionTagsParameterDefinition( '', TAG_URL, ' credential_id_here ', ' ', ' ', ' ', false , false ) tag_param.getTags()

            kinow Bruno P. Kinoshita
            cober Christoph Obermair
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: