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

ActiveChoices jenkinsProject binding to use fullName ?

    XMLWordPrintable

Details

    • Improvement
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • active-choices-plugin
    • None
    • Jenkins 2.73.3 LTS, ActiveChoicesPlugin 2.0, cloudbees-folder 5.18, CentOS 7

    Description

      Hello,

      The Jenkins jobs we are using with active-choices-plugin (reactive) are stored within a cetrain folder structure, which is enabled by cloudbees-folder plugin. There may be several jobs with the same name. Sample Jenkins folder structure:

      /RootFolder1/SubFolder1/Job1

      /RootFolder1/SubFolder2/Job1

      /RootFolder2/SubFolder1/Job1

      /Job1

      For a hudson.model.Project, getName() would return "Job1" and getFullName() would return the whole Pathname.

      This seems to make a difference while using the jenkinsProject binding, which evaluates based on the getName(). During my test this was correctly evaluated only if "Job1" was at the topmost level of hierarchy, not in any folder. (Our use case is easily obtaining the customWorkspace value from jenkinsProject dynamically... and this was just a side effect)

      https://github.com/jenkinsci/active-choices-plugin/blob/874cfcf3c18e08629fcba87a8f7c3b29bb444ad6/src/main/java/org/biouno/unochoice/util/Utils.java

      In method getProjectByName(), currently the condition checked is "p.getName().equals(projectName)".

      Please consider using "p.getFullName().equals(projectName)" instead in case of folder hierarchy.

       

      Looks like this is affected by the AbstractScriptableParameter inherited constructor, being the origin of the projectName value using AbstractItem.getName() - please consider using getFullName() instead.

      https://github.com/jenkinsci/active-choices-plugin/blob/874cfcf3c18e08629fcba87a8f7c3b29bb444ad6/src/main/java/org/biouno/unochoice/AbstractScriptableParameter.java

       

      Thanks a lot!

      Attachments

        Activity

          **Hi benediktnagy! Thanks for the detailed report.

          Please consider using "p.getFullName().equals(projectName)" instead in case of folder hierarchy.

          It sounds like a good idea, but I would need to review the javadocs and understand what would be the impact for users for vanilla job types, and also of custom jobs created by other plug-ins.

          Next release is a bug fix, including a regression. So will aim at working on this issue in the next release. Could you help with testing?

          Thanks!!

          kinow Bruno P. Kinoshita added a comment - **Hi benediktnagy ! Thanks for the detailed report. Please consider using "p.getFullName().equals(projectName)" instead in case of folder hierarchy. It sounds like a good idea, but I would need to review the javadocs and understand what would be the impact for users for vanilla job types, and also of custom jobs created by other plug-ins. Next release is a bug fix, including a regression. So will aim at working on this issue in the next release. Could you help with testing? Thanks!!
          benediktnagy Benedikt Nagy added a comment -

          Hi Bruno,

          Thanks for the quick response. Yes, I could.

          As I am rather new to this, is there any specific setup I need to have or a quick intro, which can get me started? (otherwise I will somehow figure it out)

          Thanks

          Benedikt

          benediktnagy Benedikt Nagy added a comment - Hi Bruno, Thanks for the quick response. Yes, I could. As I am rather new to this, is there any specific setup I need to have or a quick intro, which can get me started? (otherwise I will somehow figure it out) Thanks Benedikt

          People

            kinow Bruno P. Kinoshita
            benediktnagy Benedikt Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: