How to fix ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowJob cannot be cast to com.cloudbees.hudson.plugins.folder.computed.ComputedFolder

Article ID:360040235671
2 minute readKnowledge base


  • We are using a PeriodicFolderTrigger in our pipeline and are observing the following exception in the Jenkins logs:

2019-12-07 23:46:00.945+0000 [id=198] WARNING hudson.triggers.Trigger#checkTriggers: failed for org.jenkinsci.plugins.workflow.job.WorkflowJob@3099f29a[myPipeline]
java.lang.ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowJob cannot be cast to com.cloudbees.hudson.plugins.folder.computed.ComputedFolder
at hudson.triggers.Trigger.checkTriggers(
at hudson.triggers.Trigger$Cron.doRun(
at java.util.concurrent.Executors$
at java.util.concurrent.FutureTask.runAndReset(
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(
at java.util.concurrent.ScheduledThreadPoolExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
  • How to fix this issue and properly declare a Periodic Trigger on a Pipeline?


The error you see is due to the usage of a PeriodicFolderTrigger in a Pipeline. As hinted by the exception, you are trying to use a trigger (PeriodicFolderTrigger) designated for a Computed Folder on a Pipeline job. A Pipeline job is not a Computed Folder and therefore the exception is raised.

For a Pipeline job, the property you are looking for is the pipelineTriggers taking as argument an array of triggers. The triggers available are depending on your installation type and as such you probably want to look into the Pipeline Snippet Generator to find the one appropriate for you. Please refer to Pipeline: Best Practices if you are unsure how to access the Snippet Generator.

As an example, let us suppose you are looking for a Cron trigger to trigger the job every day, then you will use: properties([pipelineTriggers([cron('H H * * *')])]). For a declarative Pipeline, the same example would be:

    triggers {
        cron('H H * * *')

Refer to Declarative Pipeline: triggers for more details.