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

Active-Choice jenkinsProject variable is not available under Folder

    XMLWordPrintable

Details

    Description

      As a freestyle job at top level (not under any folder),
      the groovy script below is working
      for both "Active Choice Parameter" and "Active Choices Reactive Parameter":

      return [ jenkinsProject.getName() ]
      

      But when I move this same freestyle job under a "Cloudbees Folder",
      or when I use the same script in "Multibranch-MultiConfiguration" job
      then it will run the "Fallback script".

      Attachments

        Issue Links

          Activity

            Thanks for testing it totoroliu!!! Back to the blackboard

            kinow Bruno P. Kinoshita added a comment - Thanks for testing it totoroliu !!! Back to the blackboard

            Hi again totoroliu,

            Had a play with the Multi Branch plug-in. It was my first time using or debugging the plug-in, so feel free to correct me if anything I say here is not correct.

            I had to install the multibranch and git plug-ins in my development environment. Then created a very simple job pointing to the active-choices-plugin repository, and with a single parameter. That generated one job for each branch in the GitHub repository (interestingly, after I removed one branch I had to save the project again to sync the local projects).

            The problem is that when you save a multibranch project, it invokes the project with parameters. At that moment, the active-choices plugin stores the project name, which at that moment contains only the multibranch project name (not its subproject name). Furthermore, the plugin has access to the web request. There it can look for things like form information submitted by the user.

            There I can see the branches names, which relate to the project names. But there is no clear way to find which of those branches, the current project will be assigned.

            So it's not easy (not sure if that's doable as well) to retrieve the correct project name.

            And the reason why the multibranch project name is not displayed, is because it is not a Project Java object, it is a TopLevelItem in Jenkins, that creates Projects (FreeStyleProject or MavenProject from what I understood from quickly sifting through the code base).

            totoroliu, if you really want this feature, I suggest we close this issue for projects under a Folder, and then you can create a separate issue for multibranch-multiconfiguration jobs. Then we can work on that issue later. Does that make sense to you?

            Bruno

            kinow Bruno P. Kinoshita added a comment - Hi again totoroliu , Had a play with the Multi Branch plug-in. It was my first time using or debugging the plug-in, so feel free to correct me if anything I say here is not correct. I had to install the multibranch and git plug-ins in my development environment. Then created a very simple job pointing to the active-choices-plugin repository, and with a single parameter. That generated one job for each branch in the GitHub repository (interestingly, after I removed one branch I had to save the project again to sync the local projects). The problem is that when you save a multibranch project, it invokes the project with parameters. At that moment, the active-choices plugin stores the project name, which at that moment contains only the multibranch project name (not its subproject name). Furthermore, the plugin has access to the web request. There it can look for things like form information submitted by the user. There I can see the branches names, which relate to the project names. But there is no clear way to find which of those branches, the current project will be assigned. So it's not easy (not sure if that's doable as well) to retrieve the correct project name. And the reason why the multibranch project name is not displayed, is because it is not a Project Java object, it is a TopLevelItem in Jenkins, that creates Projects (FreeStyleProject or MavenProject from what I understood from quickly sifting through the code base). totoroliu , if you really want this feature, I suggest we close this issue for projects under a Folder, and then you can create a separate issue for multibranch-multiconfiguration jobs. Then we can work on that issue later. Does that make sense to you? Bruno
            totoroliu Rick Liu added a comment -

            (interestingly, after I removed one branch I had to save the project again to sync the local projects).

            Yes,
            or you can manually trigger the sync by running "Branch indexing" again.

            Yes, sure no problem.
            Let's close this ticket.
            and maybe rename it for free-style job only.

            How about the regular matrix (multi-configuration) job?
            JENKINS-32461 seems still broken.

            totoroliu Rick Liu added a comment - (interestingly, after I removed one branch I had to save the project again to sync the local projects). Yes, or you can manually trigger the sync by running "Branch indexing" again. Yes, sure no problem. Let's close this ticket. and maybe rename it for free-style job only. How about the regular matrix (multi-configuration) job? JENKINS-32461 seems still broken.

            Fixed for projects under folders. There will be another issue for multi-branch, and see for multi-configuration support JENKINS-32461

            kinow Bruno P. Kinoshita added a comment - Fixed for projects under folders. There will be another issue for multi-branch, and see for multi-configuration support JENKINS-32461

            Included in 1.5.0

            kinow Bruno P. Kinoshita added a comment - Included in 1.5.0

            People

              kinow Bruno P. Kinoshita
              totoroliu Rick Liu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: