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

Expose live choices to the remote API (for programmatic consumption)

      jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList

      should be @Exported in order to get the choiceList in Remote Access API.

       It allows programs retrieve choices in this way, with Remote Access API (https://www.jenkins.io/doc/book/using/remote-access-api/):

      $ curl --user username:password <JENKINS_URL>/job/<JOB_NAME>/api/json
      {
        "_class": "hudson.model.FreeStyleProject",
        ...
        "description": "",
        "displayName": "job1",
        "displayNameOrNull": null,
        "fullDisplayName": "job1",
        "fullName": "job1",
        "name": "job1",
        ...
        "property": [
          {
            "_class": "hudson.model.ParametersDefinitionProperty",
            "parameterDefinitions": [
              {
                "_class": "jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition",
                "defaultParameterValue": {
                  "_class": "hudson.model.StringParameterValue",
                  "name": "extchoice1",
                  "value": "value1"
                },
                "description": "",
                "name": "extchoice1",
                "type": "ExtensibleChoiceParameterDefinition",
                "choiceList": [
                  "value1",
                  "value2",
                  "value3"
                ]
              }
            ]
          }
        ],
        ...
      }
      

      Built-in choice parameter also exposed its choice in JENKINS-3703 to allow Eclipse retrieve choices to trigger builds. Built-in choice returns choices in REST api in this way:

              {
                "_class": "hudson.model.ChoiceParameterDefinition",
                "defaultParameterValue": {
                  "_class": "hudson.model.StringParameterValue",
                  "name": "choice1",
                  "value": "value1"
                },
                "description": "",
                "name": "choice1",
                "type": "ChoiceParameterDefinition",
                "choices": [
                  "value1",
                  "value2",
                  "value3"
                ]
              }
      

      See https://github.com/jenkinsci/extensible-choice-parameter-plugin/pull/43

          [JENKINS-63786] Expose live choices to the remote API (for programmatic consumption)

          Danny Trunk created issue -
          Danny Trunk made changes -
          Assignee New: ikedam [ ikedam ]
          Danny Trunk made changes -
          Description Original: Is it somehow possible to expose choices to the remote API job endpoint?

          Let's say we build a job with choices A and B and afterwards I remove B from the possible choices so the remote API will have only A without building the job?

           

          I need this feature especially for the System Groovy Script Choice Parameter in order to retrieve only online agents which can change from time to time independently of the job or a build.

           

          So the groovy script needs to be run on each call of `/job/JOBNAME/api/json`.
          New: `jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList` should be `@Exported` in order to get the choiceList in Remote Access API.
          Danny Trunk made changes -
          Description Original: `jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList` should be `@Exported` in order to get the choiceList in Remote Access API. New: {code:java}
          jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList{code}
          should be @Exported in order to get the choiceList in Remote Access API.
          Danny Trunk made changes -
          Description Original: {code:java}
          jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList{code}
          should be @Exported in order to get the choiceList in Remote Access API.
          New: {code:java}
          jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList{code}
          should be @Exported in order to get the choiceList in Remote Access API.

           

          See https://github.com/jenkinsci/extensible-choice-parameter-plugin/pull/43
          ikedam made changes -
          Link New: This issue relates to JENKINS-3703 [ JENKINS-3703 ]
          ikedam made changes -
          Description Original: {code:java}
          jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList{code}
          should be @Exported in order to get the choiceList in Remote Access API.

           

          See https://github.com/jenkinsci/extensible-choice-parameter-plugin/pull/43
          New: {code:java}
          jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition#getChoiceList{code}
          should be @Exported in order to get the choiceList in Remote Access API.

           It allows programs retrieve choices in this way, with Remote Access API (https://www.jenkins.io/doc/book/using/remote-access-api/):
          {code}
          $ curl --user username:password <JENKINS_URL>/job/<JOB_NAME>/api/json
          {
            "_class": "hudson.model.FreeStyleProject",
            ...
            "description": "",
            "displayName": "job1",
            "displayNameOrNull": null,
            "fullDisplayName": "job1",
            "fullName": "job1",
            "name": "job1",
            ...
            "property": [
              {
                "_class": "hudson.model.ParametersDefinitionProperty",
                "parameterDefinitions": [
                  {
                    "_class": "jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition",
                    "defaultParameterValue": {
                      "_class": "hudson.model.StringParameterValue",
                      "name": "extchoice1",
                      "value": "value1"
                    },
                    "description": "",
                    "name": "extchoice1",
                    "type": "ExtensibleChoiceParameterDefinition",
                    "choiceList": [
                      "value1",
                      "value2",
                      "value3"
                    ]
                  }
                ]
              }
            ],
            ...
          }
          {code}

          Built-in choice parameter also exposed its {{choice}} in JENKINS-3703 to allow Eclipse retrieve choices to trigger builds. Built-in choice returns choices in REST api in this way:
          {code}
                  {
                    "_class": "hudson.model.ChoiceParameterDefinition",
                    "defaultParameterValue": {
                      "_class": "hudson.model.StringParameterValue",
                      "name": "choice1",
                      "value": "value1"
                    },
                    "description": "",
                    "name": "choice1",
                    "type": "ChoiceParameterDefinition",
                    "choices": [
                      "value1",
                      "value2",
                      "value3"
                    ]
                  }
          {code}


          See https://github.com/jenkinsci/extensible-choice-parameter-plugin/pull/43
          Summary Original: Expose live choices to the remote API New: Expose live choices to the remote API (for programmatic consumption)
          ikedam made changes -
          Released As New: https://github.com/jenkinsci/extensible-choice-parameter-plugin/blob/master/CHANGELOG.adoc#170
          Assignee Original: ikedam [ ikedam ] New: Danny Trunk [ dtrunk90 ]
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]
          Michael Suhr made changes -
          Link New: This issue relates to JENKINS-66145 [ JENKINS-66145 ]

            dtrunk90 Danny Trunk
            dtrunk90 Danny Trunk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: