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

"Disable removed jobs" feature does not work with pipeline jobs

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • job-dsl-plugin
    • None

      When I use the "Disable removed jobs" feature of the Job DSL plugin, it does not work with Pipeline jobs. The job is correctly detected as an unreferenced item by ExecuteDslScripts, but it is not disabled because the Job DSL plugin is doing the disable via AbstractProject.disable():

              // Update unreferenced jobs
              for (GeneratedJob unreferencedJob : unreferenced) {
                  Item removedItem = getLookupStrategy().getItem(seedJob, unreferencedJob.getJobName(), Item.class);
                  if (removedItem != null && removedJobAction != RemovedJobAction.IGNORE) {
                      if (removedJobAction == RemovedJobAction.DELETE) {
                          removedItem.delete();
                          removed.add(unreferencedJob);
                      } else {
                          if (removedItem instanceof AbstractProject) {
                              AbstractProject project = (AbstractProject) removedItem;
                              project.checkPermission(Item.CONFIGURE);
                              if (project.isInQueue()) {
                                  project.checkPermission(Item.CANCEL); // disable() will cancel queued builds
                              }
                              project.disable();
                              disabled.add(unreferencedJob);
                          }
                      }
                  }
              }
      

      Pipeline jobs don't extend AbstractProject, so this logic won't disable them.

      This issue was previously blocked on Jenkins fixing pipeline jobs so that they support enable/disable at all. That bug has now been taken care of in JENKINS-27299 which defines enabling/disabling in ParameterizedJob rather than AbstractProject. This fix has been made available starting in Jenkins 2.61 (or 2.73 LTS). So now the Job DSL plugin needs to be updated to take advantage of this new functionality if present.

          [JENKINS-47705] "Disable removed jobs" feature does not work with pipeline jobs

          Basil Crow created issue -
          Basil Crow made changes -
          Link New: This issue depends on JENKINS-27299 [ JENKINS-27299 ]
          Daniel Spilker made changes -
          Link New: This issue is blocked by JENKINS-46899 [ JENKINS-46899 ]
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Daniel Spilker made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            daspilker Daniel Spilker
            basil Basil Crow
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: