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

          Daniel Spilker added a comment - PR: https://github.com/jenkinsci/job-dsl-plugin/pull/1101

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          docs/Home.md
          job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/ExecuteDslScripts.java
          http://jenkins-ci.org/commit/job-dsl-plugin/c99f2e6193292a4644f01dc1cc4be09f7d3b6bb5
          Log:
          fixed "Disable removed jobs" for Pipeline jobs

          [FIXES JENKINS-47705]

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: docs/Home.md job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/ExecuteDslScripts.java http://jenkins-ci.org/commit/job-dsl-plugin/c99f2e6193292a4644f01dc1cc4be09f7d3b6bb5 Log: fixed "Disable removed jobs" for Pipeline jobs [FIXES JENKINS-47705]

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          docs/Home.md
          job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/ExecuteDslScripts.java
          http://jenkins-ci.org/commit/job-dsl-plugin/7eb930ec1f005a0df7bc8668913e554e689f5214
          Log:
          Merge pull request #1101 from daspilker/JENKINS-47705

          JENKINS-47705 fixed "Disable removed jobs" for Pipeline jobs

          Compare: https://github.com/jenkinsci/job-dsl-plugin/compare/c29f3fb0af55...7eb930ec1f00

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: docs/Home.md job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/ExecuteDslScripts.java http://jenkins-ci.org/commit/job-dsl-plugin/7eb930ec1f005a0df7bc8668913e554e689f5214 Log: Merge pull request #1101 from daspilker/ JENKINS-47705 JENKINS-47705 fixed "Disable removed jobs" for Pipeline jobs Compare: https://github.com/jenkinsci/job-dsl-plugin/compare/c29f3fb0af55...7eb930ec1f00

          Basil Crow added a comment -

          This is really great! Thank you, daspilker!

          Basil Crow added a comment - This is really great! Thank you, daspilker !

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

              Created:
              Updated:
              Resolved: