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

Duplicate hudson.model.ParametersDefinitionProperty on one job

XMLWordPrintable

      I had a job which parameters is managed through declarative pipeline. EDIT: No need to copy job to cause the issue.

      Then, I migrated my pipeline from declarative to script:

      Before:

      pipeline {
        agent any
        parameters {
          string(name: 'foo')
        }
      }
      

      After:

      properties([
        parameters([
          string(name: 'foo'),
        ]),
      ])
      

      Building new job causes to have two hudson.model.ParametersDefinitionProperty attached to my job:

      Diagnose script:

      import groovy.json.JsonOutput
      import hudson.model.ParametersDefinitionProperty
      import org.jenkinsci.plugins.workflow.multibranch.JobPropertyTrackerAction
      
      def data = Jenkins.instance
          .allItems(Job.class)
          .collect {
              [
                  id: it.fullName,
                  actions: it.actions.collect {
                      def action = [
                          type: it.class.name,
                          string: "${it}",
                      ]
                      if (it instanceof JobPropertyTrackerAction) {
                          action += [
                              jobPropertyDescriptors: it.jobPropertyDescriptors,
                          ]
                      }
                      action
                  },
                  properties: it.allProperties.collect {
                      def property = [
                          type: it.class.name,
                          descriptor: [
                              type: it.descriptor.class.name,
                              category: it.descriptor.category,
                              displayName: it.descriptor.displayName,
                              id: it.descriptor.id,
                          ],
                      ]
                      if (it instanceof ParametersDefinitionProperty) {
                          property += [
                              parameterDefinitions: it.parameterDefinitions.collect {
                                  [
                                      type: it.class.name,
                                      name: it.name,
                                      description: it.description,
                                  ]
                              }
                          ]
                      }
                      property
                  },
              ]
          }
          .findAll { job ->
              [
                  job.properties.countBy { it.type },
                  job.properties.countBy { it.descriptor.type },
                  job.properties.countBy { it.descriptor.id },
              ].any {
                  it.any { _,count -> count > 1 }
              }
          }
      
      println(JsonOutput.prettyPrint(JsonOutput.toJson(data)))
      

      Result:

      [
          {
              "id": "Demo/copy",
              "properties": [
                  {
                      "type": "jenkins.model.BuildDiscarderProperty",
                      "descriptor": {
                          "type": "jenkins.model.BuildDiscarderProperty$DescriptorImpl",
                          "category": {
                              "shortDescription": "Configurer les param\u00e8tres g\u00e9n\u00e9raux et les chemins de fichiers.",
                              "displayName": "Configurer le syst\u00e8me"
                          },
                          "displayName": "Supprimer les anciens builds",
                          "id": "jenkins.model.BuildDiscarderProperty"
                      }
                  },
                  {
                      "type": "com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty",
                      "descriptor": {
                          "type": "com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty$DescriptorImpl",
                          "category": {
                              "shortDescription": "Configurer les param\u00e8tres g\u00e9n\u00e9raux et les chemins de fichiers.",
                              "displayName": "Configurer le syst\u00e8me"
                          },
                          "displayName": "GitLab connection",
                          "id": "com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty"
                      }
                  },
                  {
                      "type": "com.sonyericsson.rebuild.RebuildSettings",
                      "descriptor": {
                          "type": "com.sonyericsson.rebuild.RebuildSettings$DescriptorImpl",
                          "category": {
                              "shortDescription": "Configurer les param\u00e8tres g\u00e9n\u00e9raux et les chemins de fichiers.",
                              "displayName": "Configurer le syst\u00e8me"
                          },
                          "displayName": "Rebuild Settings",
                          "id": "com.sonyericsson.rebuild.RebuildSettings"
                      }
                  },
                  {
                      "type": "hudson.model.ParametersDefinitionProperty",
                      "descriptor": {
                          "type": "hudson.model.ParametersDefinitionProperty$DescriptorImpl",
                          "category": {
                              "shortDescription": "Configurer les param\u00e8tres g\u00e9n\u00e9raux et les chemins de fichiers.",
                              "displayName": "Configurer le syst\u00e8me"
                          },
                          "displayName": "Ce build a des param\u00e8tres",
                          "id": "hudson.model.ParametersDefinitionProperty"
                      }
                  },
                  {
                      "type": "hudson.plugins.jobConfigHistory.JobLocalConfiguration",
                      "descriptor": {
                          "type": "hudson.plugins.jobConfigHistory.JobLocalConfiguration$DescriptorImpl",
                          "category": {
                              "shortDescription": "Configurer les param\u00e8tres g\u00e9n\u00e9raux et les chemins de fichiers.",
                              "displayName": "Configurer le syst\u00e8me"
                          },
                          "displayName": "changeReasonComment_holder",
                          "id": "hudson.plugins.jobConfigHistory.JobLocalConfiguration"
                      }
                  },
                  {
                      "type": "hudson.model.ParametersDefinitionProperty",
                      "descriptor": {
                          "type": "hudson.model.ParametersDefinitionProperty$DescriptorImpl",
                          "category": {
                              "shortDescription": "Configurer les param\u00e8tres g\u00e9n\u00e9raux et les chemins de fichiers.",
                              "displayName": "Configurer le syst\u00e8me"
                          },
                          "displayName": "Ce build a des param\u00e8tres",
                          "id": "hudson.model.ParametersDefinitionProperty"
                      }
                  }
              ]
          }
      ]
      

      I was able to remove all job parameter properties with:

      Script (Console/Pipeline):

      while (job.getProperty(ParametersDefinitionProperty.class) != null) {
          job.removeProperty(ParametersDefinitionProperty.class)
      }
      

      From Web UI: unchecking This project is parameterized.

            Unassigned Unassigned
            loganmzz Logan Mzz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: