Skip to content

Commit

Permalink
test if job class responds to #isDisabled in job_list_json
Browse files Browse the repository at this point in the history
Instead of special casing classes which are known not to respond to the
`isDisabled()` method, use introspection.

resolves voxpupuli#551
  • Loading branch information
jhoblitt committed Apr 7, 2016
1 parent 4d82df1 commit c533c65
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions files/puppet_helper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,14 @@ class Actions {
def jobs = util.findJobs(Jenkins.getInstance())

def allInfo = jobs.collect { path, job ->
// at least these job classes do not respond to respond to #isDisabled:
// - org.jenkinsci.plugins.workflow.job.WorkflowJob
// - com.cloudbees.hudson.plugins.folder.Folder
def enabled = false
// folders don't respond to #isDisabled
if (job.getClass().getName() != 'com.cloudbees.hudson.plugins.folder.Folder') {
if (job.metaClass.respondsTo(job, 'isDisabled')) {
enabled = !job.isDisabled()
}

[
name: path,
config: job.getConfigFile().getFile().getText('utf-8'),
Expand Down

0 comments on commit c533c65

Please sign in to comment.