MCMicS / jenkins-control-plugin

Jenkins integration in IDEA Platforms
https://plugins.jetbrains.com/plugin/6110-jenkins-control-plugin
Apache License 2.0
250 stars 123 forks source link

CascadeChoiceParameter is unsupported #251

Open psuvjd opened 4 years ago

psuvjd commented 4 years ago

image Could you add support for this? possibly similar to #249

The Jenkins plugin is https://plugins.jenkins.io/uno-choice/.

The parameter type is "Active Choices Reactive Parameter". image

MCMicS commented 4 years ago

I will look at this plugin api result these days. Maybe it will released next week if all data are available

MCMicS commented 4 years ago

We have an similar issue #171 Do you have a sample job pipeline for this or some snippets to configure a job for your needed settings

My Config: config_mcmics.zip

MCMicS commented 4 years ago

I cannot get any values from API

{
  "_class": "hudson.model.FreeStyleProject",
  "property": [
    {
      "_class": "hudson.model.ParametersDefinitionProperty",
      "parameterDefinitions": [
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "value": "Option 1"
          },
          "description": "Active Choices Single",
          "name": "Active Choices Single",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "value": "Option 1"
          },
          "description": "Active Choices Multi",
          "name": "Active Choices Multi",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "value": "Option 1"
          },
          "description": "",
          "name": "Active Choices Radio",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "value": "Option 1"
          },
          "description": "",
          "name": "ActiveChoicesCheck",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.CascadeChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "value": "Option 1"
          },
          "description": "return ['Option 1', 'Option 2', 'Option 3']",
          "name": "Reactive Single",
          "type": "CascadeChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.DynamicReferenceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "value": ""
          },
          "description": "",
          "name": "Active Choices Reference Parameter",
          "type": "DynamicReferenceParameter"
        }
      ]
    }
  ]
}

I retrieve only some default parameters. I can offer an simple text area input field but this is not helping because you have to enter all values manually

psuvjd commented 4 years ago

I used the type of "CascadeChoiceParameter", it support selecting some choices, similar to 'check box' in html. I can input the values seperated by comma in text area instead

MCMicS commented 4 years ago

I will try some possible solutions on weekend or next begin

psuvjd commented 4 years ago

thanks

hectorlavado99 commented 2 years ago

Hi, @MCMicS

¿do you think you can fix it?

MCMicS commented 2 years ago

I will hav a look the API again if I can cann needed data. Can you provide a sample pipeline (or job configuration) to test against

MCMicS commented 2 years ago

I will test with following simple pipeline:

properties([
  parameters([
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_SINGLE_SELECT',
      name: 'Single',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Single 1', 'Single 2:selected']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_MULTI_SELECT',
      name: 'Multi',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Multi 1:selected', 'Multi 2']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_CHECKBOX',
      name: 'Checkbox',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Check 1', 'Check 2']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_RADIO',
      name: 'Radio',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Radio 1', 'Radio 2']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'CascadeChoiceParameter',
      choiceType: 'PT_SINGLE_SELECT',
      name: 'CascadeToSingle',
      referencedParameters: 'Single',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['none', Single]",
            sandbox: 'true',
            classpath: []
        ]
      ]
   ]
  ])
])

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo "Single: ${params.Single}"
        echo "Multi: ${params.Multi}"
        echo "Checkbox: ${params.Checkbox}"
        echo "Radio: ${params.Radio}"
        echo "Cascade: ${params.CascadeToSingle}"
      }
    }
  }
}

with following API result:

{
  "_class": "org.jenkinsci.plugins.workflow.job.WorkflowJob",
  "property": [
    {
      "_class": "hudson.model.ParametersDefinitionProperty",
      "parameterDefinitions": [
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "name": "Single",
            "value": "Single 2"
          },
          "description": null,
          "name": "Single",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "name": "Multi",
            "value": "Multi 1"
          },
          "description": null,
          "name": "Multi",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "name": "Checkbox",
            "value": "Check 1"
          },
          "description": null,
          "name": "Checkbox",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.ChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "name": "Radio",
            "value": "Radio 1"
          },
          "description": null,
          "name": "Radio",
          "type": "ChoiceParameter"
        },
        {
          "_class": "org.biouno.unochoice.CascadeChoiceParameter",
          "defaultParameterValue": {
            "_class": "hudson.model.StringParameterValue",
            "name": "CascadeToSingle",
            "value": ""
          },
          "description": null,
          "name": "CascadeToSingle",
          "type": "CascadeChoiceParameter"
        }
      ]
    }
  ]
}

Still no retrieve all possible values via API. So I cannot get all possible values and can offer an textinput to enter values manually.

I create an Issue. Maybe the values can be exported: https://issues.jenkins.io/browse/JENKINS-68206

If I offer a simple textfield with default value will this work for you?

I try some other api calls instead

hectorlavado99 commented 2 years ago

Hi,

Add more information: image image

If I offer a simple textfield with default value will this work for you? It wouldn't be the best solution but at least I could run it. so the answer is yes

Thanks!

MCMicS commented 2 years ago

@hectorlavado99 Could you please try following build https://plugins.jetbrains.com/plugin/6110-jenkins-control/versions/eap/167592

Pipeline:


properties([
  parameters([
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_SINGLE_SELECT',
      name: 'Single',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Single 1', 'Single 2:selected']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_MULTI_SELECT',
      name: 'Multi',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Multi 1:selected', 'Multi 2']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_CHECKBOX',
      name: 'Checkbox',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Check 1', 'Check 2']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'ChoiceParameter',
      choiceType: 'PT_RADIO',
      name: 'Radio',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Radio 1', 'Radio 2']",
            sandbox: 'true',
            classpath: []
        ]

      ]
    ],
    [
      $class: 'CascadeChoiceParameter',
      choiceType: 'PT_SINGLE_SELECT',
      name: 'CascadeToSingle',
      referencedParameters: 'Single',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['none', Single]",
            sandbox: 'true',
            classpath: []
        ]
      ]
   ],
    [
      $class: 'DynamicReferenceParameter',
      choiceType: 'ET_TEXT_BOX',
      name: 'DynamicReference ',
      referencedParameters: 'Single',
      script: [
        $class: 'GroovyScript',
        script: [
            script: "return ['Reference 1', 'Reference 2:selected']",
            sandbox: 'true',
            classpath: []
        ]
      ]
   ]
  ])
])

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo "Single: ${params.Single}"
        echo "Multi: ${params.Multi}"
        echo "Checkbox: ${params.Checkbox}"
        echo "Radio: ${params.Radio}"
        echo "Cascade: ${params.CascadeToSingle}"
        echo "DynamicReference: ${params.DynamicReference}"
      }
    }
  }
}

Result in IDEA grafik