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

Git Parameter Plugin not expose type to API anymore

      I have a pipeline job as follows:

      // Using git without checkout
      pipeline {
        agent any
        parameters {
          gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'JOB_TAG', type: 'PT_TAG'
          gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'JOB_BRANCH', type: 'PT_BRANCH'
          gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'JOB_BRANCH_TAG', type: 'PT_BRANCH_TAG'
          gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'JOB_REVISION', type: 'PT_REVISION'
          gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'JOB_PULL_REQUEST', type: 'PT_PULL_REQUEST'
        }
        stages {
          stage('Example') {
            steps {
              echo "PT_TAG: ${params.JOB_TAG}"
              echo "PT_BRANCH: ${params.JOB_BRANCH}"
              echo "PT_BRANCH_TAG: ${params.JOB_BRANCH_TAG}"
              echo "PT_REVISION: ${params.JOB_REVISION}"
              echo "PT_PULL_REQUEST: ${params.JOB_PULL_REQUEST}"
            }
          }
        }
      }
      

      The API Results in following:

      {"_class":"org.jenkinsci.plugins.workflow.job.WorkflowJob","property":[{"_class":"hudson.model.ParametersDefinitionProperty","parameterDefinitions":[{"_class":"net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition","name":"JOB_TAG","type":"GitParameterDefinition"},{"_class":"net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition","name":"JOB_BRANCH","type":"GitParameterDefinition"},{"_class":"net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition","name":"JOB_BRANCH_TAG","type":"GitParameterDefinition"},{"_class":"net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition","name":"JOB_REVISION","type":"GitParameterDefinition"},{"_class":"net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition","name":"JOB_PULL_REQUEST","type":"GitParameterDefinition"}]}]}
      

      The type is always 'GitParameterDefinition'. Before it was set to the selected Type (PT_TAG, PT_BRANCH, PT_BRANCH_TAG, PT_REVISION, PT_PULL_REQUEST)

      I check the type for my plugin and there you see old and current API value: https://github.com/MCMicS/jenkins-control-plugin/issues/366#issuecomment-1084101319

          [JENKINS-68168] Git Parameter Plugin not expose type to API anymore

          Probably caused by https://github.com/jenkinsci/git-parameter-plugin/pull/91, which was intended to fix JENKINS-42435.

          From JENKINS-42435, it seems the "type":"PT_BRANCH_TAG" etc. caused a problem in Blue Ocean. The GitParameterDefinition class now has getParameterType() for reading "PT_BRANCH_TAG" but perhaps that needs an @Exported annotation to make it show up in the API. Before the JENKINS-42435 fix, the @Override public String getType() method inherited @Exported from ParameterDefinition.getType() (javadoc).

          Kalle Niemitalo added a comment - Probably caused by https://github.com/jenkinsci/git-parameter-plugin/pull/91 , which was intended to fix JENKINS-42435 . From JENKINS-42435 , it seems the "type":"PT_BRANCH_TAG" etc. caused a problem in Blue Ocean. The GitParameterDefinition class now has getParameterType() for reading "PT_BRANCH_TAG" but perhaps that needs an @Exported annotation to make it show up in the API. Before the JENKINS-42435 fix, the @Override public String getType() method inherited @Exported from ParameterDefinition.getType() ( javadoc ).

          Michael Suhr added a comment -

          thanks for clarfiy. I also added in my code some logic to handle it for now. This will be ok because I render all as ListBoxes

          Michael Suhr added a comment - thanks for clarfiy. I also added in my code some logic to handle it for now. This will be ok because I render all as ListBoxes

            klimas7 Boguslaw Klimas
            mcmics Michael Suhr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: