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

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

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: job-dsl-plugin
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

            Show
            daspilker Daniel Spilker added a comment - PR: https://github.com/jenkinsci/job-dsl-plugin/pull/1101
            Hide
            scm_issue_link 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]

            Show
            scm_issue_link 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]
            Hide
            scm_issue_link 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

            Show
            scm_issue_link 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
            Hide
            basil Basil Crow added a comment -

            This is really great! Thank you, Daniel Spilker!

            Show
            basil Basil Crow added a comment - This is really great! Thank you, Daniel Spilker !

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: