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

Ability to share variable across two or more active choice parameters

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • active-choices-plugin
    • None

      Let say I have a jenkins build with one active choice and another active choice reactive parameter. In active choice parameter I run some groovy commands to populate some map variable, which have information of both active choice parameter and active choice reactive parameter. Now since I can not share the map variable across two active choice parameters, I have to run the same groovy commands again in active choice reactive parameter.

      It is highly desirable that I should be able to share specific variable across two or more active choice parameters to avoid duplication of work across active choice parameters of a jenkins build.

          [JENKINS-43622] Ability to share variable across two or more active choice parameters

          Hummm. This again sounds doable with current parameter types and plug-in features, but not very straightforward. Will wait for ioannis to be able to take a look and say whether he would be able to achieve what is described here, or if we would need to change the code

          Bruno P. Kinoshita added a comment - Hummm. This again sounds doable with current parameter types and plug-in features, but not very straightforward. Will wait for ioannis to be able to take a look and say whether he would be able to achieve what is described here, or if we would need to change the code

          Ioannis Moutsatsos added a comment - - edited

          Hi bipulr. I'm not sure I fully understand your case. You may want to create simple diagram to explain But you can always create an Active Choices Reference parameter that can be used by multiple downstream parameters. Something like this:

          Using an AC-reactRef that returns a text input element as hidden formatted HTML you can easily encode your map and pass it to downstream AC parameters. I like encoding my maps in a way that I can use groovy directly to evaluate them.

          Something like this:

           

          select = '[SERIAL_ID:[operator:\'in\', value:1..5], NUM2:[operator:\'>=\',value:7], TYPE:[\'DynamicReferenceParameter\']]'
          selectClauses=evaluate(select)
          

           

          Ioannis Moutsatsos added a comment - - edited Hi  bipulr . I'm not sure I fully understand your case. You may want to create simple diagram to explain But you can always create an Active Choices Reference parameter that can be used by multiple downstream parameters. Something like this: Using an AC-reactRef that returns a text input element as hidden formatted HTML you can easily encode your map and pass it to downstream AC parameters. I like encoding my maps in a way that I can use groovy directly to evaluate them. Something like this:   select = '[SERIAL_ID:[ operator :\' in\ ', value:1..5], NUM2:[ operator :\' >=\ ',value:7], TYPE:[\' DynamicReferenceParameter\ ']]' selectClauses=evaluate(select)  

          Bipul Raj added a comment -

          ioannis I explain my problem, below is the scenario I have.

          Activice choice parameter

          • name - Category1
          • Groovy script - contruct testMap based on several things. Return first level entries of testMap. Note I do not want to return whole testMap which contain information about other categories also. testMap is actually maps of maps.

          Active choice reactive prarmeter

          • name Category2
          • Referenced parameters - Category 1
          • Groovy script- construct testMap again. Based on what is selected for Category1, return second level entries of testMap.

          Now here I have to contruct testMap again in both active choice parameter and active choice reactive parameter, which can be avoided if I construct it only once in Category1 and if I can share testMap across active choice parameters. Note that I have N number of such categories and each category return specific level of testMap based on what are selected for previous categories. So I endup constructing testMap in all categories which is becoming too slow and costly.

          So far I did not get what solution you are proposing, but looking into it more.

          Bipul Raj added a comment - ioannis I explain my problem, below is the scenario I have. Activice choice parameter name - Category1 Groovy script - contruct testMap based on several things. Return first level entries of testMap. Note I do not want to return whole testMap which contain information about other categories also. testMap is actually maps of maps. Active choice reactive prarmeter name Category2 Referenced parameters - Category 1 Groovy script- construct testMap again. Based on what is selected for Category1, return second level entries of testMap. Now here I have to contruct testMap again in both active choice parameter and active choice reactive parameter, which can be avoided if I construct it only once in Category1 and if I can share testMap across active choice parameters. Note that I have N number of such categories and each category return specific level of testMap based on what are selected for previous categories. So I endup constructing testMap in all categories which is becoming too slow and costly. So far I did not get what solution you are proposing, but looking into it more.

          Bipul Raj added a comment -

          ioannis Can you please suggest if the solution you are proposing would solve the problem I am having?
          Please let me know if you want me to explain the problem more.

          Bipul Raj added a comment - ioannis Can you please suggest if the solution you are proposing would solve the problem I am having? Please let me know if you want me to explain the problem more.

          Active Choices Reactive and Reactive Reference parameters support parameter sharing by passing a reference to another Jenkins build parameter (that could be another Active Choice parameter). These parameters are passed as simple strings (not as groovy/java objects). So, however, you want to do it you must pass it as a string. You could use a AC reactive reference (formatted as hidden HTML) as this shared intermediate.

          Ioannis Moutsatsos added a comment - Active Choices Reactive and Reactive Reference parameters support parameter sharing by passing a reference to another Jenkins build parameter (that could be another Active Choice parameter). These parameters are passed as simple strings (not as groovy/java objects). So, however, you want to do it you must pass it as a string. You could use a AC reactive reference (formatted as hidden HTML) as this shared intermediate.

            kinow Bruno P. Kinoshita
            bipulr Bipul Raj
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: