Skip to content

[JENKINS-69621] P4 trigger cause ClassCastException in multi-configuration projects #735

@jenkins-infra-bot

Description

@jenkins-infra-bot

I have two jobs running side by side, a "Freestyle" job and a Matrix or "Multi-Configuration Project" (MCP) configured to do the same simple tasks. For both jobs after a Perforce trigger is received, the jobs will execute a P4-sync of the workspace, then use Powershell to Write-Output a simple message, and finally make a Slack notification.

When a P4 trigger is received the Freestyle job executes as expected. However after the Matrix/MCP job is notified by the same trigger event, it seems unable to process that a change has taken place and never starts the P4-sync or other steps.

By examining the jenkins.err.log I can see an exception is being thrown when Jenkins tries to process the job.

jenkins.err.log
2022-09-15 17:29:26.301+0000 [id=12008]	WARNING	h.p.b.g.GlobalTimeOutConfiguration#timeOutFor: Tests_P4Trigger_NameVars#1 cannot allow individual jobs to overwrite timeout due to ClassCastException
java.lang.ClassCastException: class hudson.matrix.MatrixProject cannot be cast to class hudson.model.Project (hudson.matrix.MatrixProject is in unnamed module of loader jenkins.util.URLClassLoader2 @​ab11188; hudson.model.Project is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @​33bc72d1)
	at hudson.plugins.build_timeout.global.GlobalTimeOutConfiguration.timeOutFor(GlobalTimeOutConfiguration.java:91)
	at hudson.plugins.build_timeout.global.GlobalTimeOutRunListener.setUpEnvironment(GlobalTimeOutRunListener.java:43)
	at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:615)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:483)
	at hudson.model.Run.execute(Run.java:1899)
	at hudson.matrix.MatrixBuild.run(MatrixBuild.java:323)
	at hudson.model.ResourceController.execute(ResourceController.java:107)
	at hudson.model.Executor.run(Executor.java:449)
2022-09-15 17:29:27.342+0000 [id=12008]	INFO	o.j.p.p.w.ManualWorkspaceImpl#setClient: P4: Creating manual client: jenkins-built-in-Tests_P4Trigger_NameVars--1
2022-09-15 17:29:27.353+0000 [id=73]	INFO	o.j.p.p.w.ManualWorkspaceImpl#setClient: P4: Creating manual client: jenkins-BP-JNKND-VS19-6-Tests_P4Trigger_SlackPost-0
2022-09-15 17:29:27.602+0000 [id=11722]	INFO	o.j.plugins.p4.trigger.P4Hook#probeJobs: P4: probing: DAFI_7-66-SIEI_CLI_VS19

Note the Matrix/MCP job will run successfully if started manually or by a timer. The job only fails after it receives a P4 trigger event.

Reproducibility: Always

Steps to Reproduce:

  1. Setup a Jenkins server to receive P4 Triggers.
  2. Setup a Perforce server that triggers a Jenkins server.
  3. Create a Matrix/MCP project that has a workspace mapping from the Perforce server.
  4. Use the Manual P4 trigger to run job for the first time.
    • Note the first run will work.
  5. Next submit a change in the Perforce server that will send a trigger to the Jenkins server.

Result:
Jenkins will receive the P4 Trigger, but during the processing of the job the exception above will be thrown, and the Matrix/MCP job will not execute.

Expected Result:
That a Matrix/MCP job would function like a Freestyle job. When a P4 trigger is received the required processing would not throw an exception and instead continue through all the steps.


Originally reported by jgorden_sie, imported from: P4 trigger cause ClassCastException in multi-configuration projects
  • assignee: kohsuke
  • status: Open
  • priority: Minor
  • component(s): matrix-project-plugin
  • label(s): classcastexception, matrix-project
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-06
Raw content of original issue

I have two jobs running side by side, a "Freestyle" job and a Matrix or "Multi-Configuration Project" (MCP) configured to do the same simple tasks. For both jobs after a Perforce trigger is received, the jobs will execute a P4-sync of the workspace, then use Powershell to Write-Output a simple message, and finally make a Slack notification.

When a P4 trigger is received the Freestyle job executes as expected. However after the Matrix/MCP job is notified by the same trigger event, it seems unable to process that a change has taken place and never starts the P4-sync or other steps.

By examining the jenkins.err.log I can see an exception is being thrown when Jenkins tries to process the job.

jenkins.err.log
2022-09-15 17:29:26.301+0000 [id=12008]	WARNING	h.p.b.g.GlobalTimeOutConfiguration#timeOutFor: Tests_P4Trigger_NameVars#1 cannot allow individual jobs to overwrite timeout due to ClassCastException
java.lang.ClassCastException: class hudson.matrix.MatrixProject cannot be cast to class hudson.model.Project (hudson.matrix.MatrixProject is in unnamed module of loader jenkins.util.URLClassLoader2 @ab11188; hudson.model.Project is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @33bc72d1)
	at hudson.plugins.build_timeout.global.GlobalTimeOutConfiguration.timeOutFor(GlobalTimeOutConfiguration.java:91)
	at hudson.plugins.build_timeout.global.GlobalTimeOutRunListener.setUpEnvironment(GlobalTimeOutRunListener.java:43)
	at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:615)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:483)
	at hudson.model.Run.execute(Run.java:1899)
	at hudson.matrix.MatrixBuild.run(MatrixBuild.java:323)
	at hudson.model.ResourceController.execute(ResourceController.java:107)
	at hudson.model.Executor.run(Executor.java:449)
2022-09-15 17:29:27.342+0000 [id=12008]	INFO	o.j.p.p.w.ManualWorkspaceImpl#setClient: P4: Creating manual client: jenkins-built-in-Tests_P4Trigger_NameVars--1
2022-09-15 17:29:27.353+0000 [id=73]	INFO	o.j.p.p.w.ManualWorkspaceImpl#setClient: P4: Creating manual client: jenkins-BP-JNKND-VS19-6-Tests_P4Trigger_SlackPost-0
2022-09-15 17:29:27.602+0000 [id=11722]	INFO	o.j.plugins.p4.trigger.P4Hook#probeJobs: P4: probing: DAFI_7-66-SIEI_CLI_VS19

Note the Matrix/MCP job will run successfully if started manually or by a timer. The job only fails after it receives a P4 trigger event.

Reproducibility: Always

Steps to Reproduce:

  1. Setup a Jenkins server to receive P4 Triggers.
  2. Setup a Perforce server that triggers a Jenkins server.
  3. Create a Matrix/MCP project that has a workspace mapping from the Perforce server.
  4. Use the Manual P4 trigger to run job for the first time.
    • Note the first run will work.
  5. Next submit a change in the Perforce server that will send a trigger to the Jenkins server.

Result: Jenkins will receive the P4 Trigger, but during the processing of the job the exception above will be thrown, and the Matrix/MCP job will not execute.

Expected Result: That a Matrix/MCP job would function like a Freestyle job. When a P4 trigger is received the required processing would not throw an exception and instead continue through all the steps.

environment
Jenkins: 2.361.1<br/>
OS: Windows Server 2019 - 10.0<br/>
---<br/>
ace-editor:1.1<br/>
active-directory:2.26<br/>
antisamy-markup-formatter:2.7<br/>
apache-httpcomponents-client-4-api:4.5.13-138.v4e7d9a_7b_a_e61<br/>
authentication-tokens:1.4<br/>
bootstrap4-api:4.6.0-5<br/>
bootstrap5-api:5.2.0-3<br/>
bouncycastle-api:2.26<br/>
branch-api:2.1046.v0ca_37783ecc5<br/>
build-timeout:1.24<br/>
caffeine-api:2.9.3-65.v6a_47d0f4d1fe<br/>
checks-api:1.7.5<br/>
cloudbees-folder:6.758.vfd75d09eea_a_1<br/>
command-launcher:84.v4a_97f2027398<br/>
conditional-buildstep:1.4.2<br/>
credentials:1143.vb_e8b_b_ceee347<br/>
credentials-binding:523.vd859a_4b_122e6<br/>
dark-theme:245.vb_a_2b_b_010ea_96<br/>
display-url-api:2.3.6<br/>
durable-task:500.v8927d9fd99d8<br/>
echarts-api:5.3.3-1<br/>
email-ext:2.91<br/>
external-monitor-job:192.ve979ca_8b_3ccd<br/>
font-awesome-api:6.1.2-1<br/>
generic-webhook-trigger:1.84<br/>
git:4.11.5<br/>
git-changelog:3.23<br/>
git-client:3.11.2<br/>
git-parameter:0.9.17<br/>
git-server:99.va_0826a_b_cdfa_d<br/>
github:1.35.0<br/>
github-api:1.303-400.v35c2d8258028<br/>
github-branch-source:1694.vd46793a_c4a_57<br/>
github-oauth:0.39<br/>
gitlab-api:5.0.1-78.v47a_45b_9f78b_7<br/>
gitlab-branch-source:636.v55fd8144d335<br/>
gitlab-logo:1.0.5<br/>
gitlab-merge-request-jenkins:2.0.0<br/>
gitlab-plugin:1.5.35<br/>
handlebars:3.0.8<br/>
handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953<br/>
instance-identity:116.vf8f487400980<br/>
jackson2-api:2.13.3-285.vc03c0256d517<br/>
jakarta-activation-api:2.0.1-1<br/>
jakarta-mail-api:2.0.1-1<br/>
javadoc:226.v71211feb_e7e9<br/>
javax-activation-api:1.2.0-4<br/>
javax-mail-api:1.6.2-7<br/>
jaxb:2.3.6-1<br/>
jdk-tool:55.v1b_32b_6ca_f9ca<br/>
jersey2-api:2.37-1<br/>
jjwt-api:0.11.5-77.v646c772fddb_0<br/>
jquery:1.12.4-1<br/>
jquery-detached:1.2.1<br/>
jquery3-api:3.6.0-4<br/>
jsch:0.1.55.61.va_e9ee26616e7<br/>
junit:1119.1121.vc43d0fc45561<br/>
ldap:2.12<br/>
lockable-resources:2.16<br/>
log-parser:2.2<br/>
mailer:438.v02c7f0a_12fa_4<br/>
mapdb-api:1.0.9-28.vf251ce40855d<br/>
matrix-auth:3.1.5<br/>
matrix-project:785.v06b_7f47b_c631<br/>
maven-plugin:3.19<br/>
mina-sshd-api-common:2.8.0-36.v8e25ce90d4b_1<br/>
mina-sshd-api-core:2.8.0-36.v8e25ce90d4b_1<br/>
momentjs:1.1.1<br/>
msbuild:1.30<br/>
naginator:1.18.1<br/>
nunit:0.27<br/>
okhttp-api:4.9.3-108.v0feda04578cf<br/>
p4:1.13.0<br/>
pam-auth:1.10<br/>
parameterized-trigger:2.45<br/>
pipeline-build-step:2.18<br/>
pipeline-github-lib:38.v445716ea_edda_<br/>
pipeline-githubnotify-step:49.vf37bf92d2bc8<br/>
pipeline-graph-analysis:195.v5812d95a_a_2f9<br/>
pipeline-groovy-lib:612.v84da_9c54906d<br/>
pipeline-input-step:449.v77f0e8b_845c4<br/>
pipeline-milestone-step:101.vd572fef9d926<br/>
pipeline-model-api:2.2114.v2654ca_721309<br/>
pipeline-model-definition:2.2114.v2654ca_721309<br/>
pipeline-model-extensions:2.2114.v2654ca_721309<br/>
pipeline-rest-api:2.24<br/>
pipeline-stage-step:296.v5f6908f017a_5<br/>
pipeline-stage-tags-metadata:2.2114.v2654ca_721309<br/>
pipeline-stage-view:2.24<br/>
plain-credentials:139.ved2b_9cf7587b<br/>
plugin-util-api:2.17.0<br/>
popper-api:1.16.1-3<br/>
popper2-api:2.11.6-1<br/>
powershell:1.7<br/>
resource-disposer:0.20<br/>
run-condition:1.5<br/>
scm-api:621.vda_a_b_055e58f7<br/>
script-security:1175.v4b_d517d6db_f0<br/>
slack:616.v03b_1e98d13dd<br/>
snakeyaml-api:1.31-84.ve43da_fb_49d0b<br/>
ssh-credentials:305.v8f4381501156<br/>
sshd:3.249.v2dc2ea_416e33<br/>
structs:324.va_f5d6774f3a_d<br/>
theme-manager:1.5<br/>
throttle-concurrents:2.9<br/>
timestamper:1.19<br/>
token-macro:308.v4f2b_ed62b_b_16<br/>
trilead-api:1.67.vc3938a_35172f<br/>
variant:59.vf075fe829ccb<br/>
violation-comments-to-gitlab:2.55<br/>
windows-slaves:1.8.1<br/>
wix:1.12<br/>
workflow-aggregator:590.v6a_d052e5a_a_b_5<br/>
workflow-api:1192.v2d0deb_19d212<br/>
workflow-basic-steps:994.vd57e3ca_46d24<br/>
workflow-cps:2759.v87459c4eea_ca_<br/>
workflow-durable-task-step:1199.v02b_9244f8064<br/>
workflow-job:1232.v5a_4c994312f1<br/>
workflow-multibranch:716.vc692a_e52371b_<br/>
workflow-scm-step:400.v6b_89a_1317c9a_<br/>
workflow-step-api:639.v6eca_cd8c04a_a_<br/>
workflow-support:838.va_3a_087b_4055b<br/>
ws-cleanup:0.43

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions