jenkinsci / pipeline-agent-build-history-plugin

Agent Build History with pipeline jobs for Jenkins
https://plugins.jenkins.io/pipeline-agent-build-history/
MIT License
2 stars 2 forks source link

Extended build history for a job fails #21

Closed Tiaxi closed 4 months ago

Tiaxi commented 4 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.440.1 OS: Linux - 5.15.0-91-generic Java: 21.0.2 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- Office-365-Connector:4.21.0 Parameterized-Remote-Trigger:3.2.0 PrioritySorter:5.1.0 ace-editor:1.1 ansicolor:1.0.4 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 anything-goes-formatter:19.v3e2b_1b_3e0ee5 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 bootstrap5-api:5.3.2-4 bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9 branch-api:2.1152.v6f101e97dd77 build-timeout:1.32 build-user-vars-plugin:1.9 build-with-parameters:76.v9382db_f78962 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 cloudbees-disk-usage-simple:203.v3f46a_7462b_1a_ cloudbees-folder:6.901.vb_4c7a_da_75da_3 command-launcher:107.v773860566e2e commons-httpclient3-api:3.1-3 commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-95.v22a_d30ee5d36 compact-columns:1.185.vf3851b_4d31fe conditional-buildstep:1.4.3 config-file-provider:968.ve1ca_eb_913f8c configuration-as-code:1775.v810dc950b_514 copyartifact:722.v0662a_9b_e22a_c credentials:1319.v7eb_51b_3a_c97b_ credentials-binding:657.v2b_19db_7d6e6d dashboard-view:2.508.va_74654f026d1 data-tables-api:1.13.8-4 description-setter:239.vd0a_6b_785f92d display-url-api:2.200.vb_9327d658781 downstream-build-cache:1.7 durable-task:550.v0930093c4b_a_6 echarts-api:5.4.3-4 email-ext:2.104 envinject:2.908.v66a_774b_31d93 envinject-api:1.199.v3ce31253ed13 extensible-choice-parameter:1.8.1 external-monitor-job:215.v2e88e894db_f8 extra-columns:1.26 font-awesome-api:6.5.1-3 generic-webhook-trigger:2.0.0 git:5.2.1 git-client:4.6.0 gitlab-plugin:1.8.0 gradle:2.10 groovy:457.v99900cb_85593 gson-api:2.10.1-15.v0d99f670e0a_7 hidden-parameter:237.v4b_df26c7a_f0e http_request:1.18 instance-identity:185.v303dc7c645f9 ionicons-api:56.v1b_1c8c49374e jackson2-api:2.16.1-373.ve709c6871598 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javadoc:243.vb_b_503b_b_45537 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:73.vddf737284550 jersey2-api:2.41-133.va_03323b_a_1396 job-dsl:1.87 jobConfigHistory:1229.v3039470161a_d joda-time-api:2.12.7-29.v5a_b_e3a_82269a_ jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240205-27.va_007549e895c json-path-api:2.9.0-33.v2527142f2e1d junit:1259.v65ffcef24a_88 ldap:711.vb_d1a_491714dc leastload:3.0.0 locale:431.v3435fa_8f8445 lockable-resources:1243.v346d600eea_24 mailer:463.vedf8358e006b_ mapdb-api:1.0.9-28.vf251ce40855d mask-passwords:173.v6a_077a_291eb_5 matrix-auth:3.2.1 matrix-project:822.824.v14451b_c0fd42 maven-plugin:3.23 metrics:4.2.21-449.v6960d7c54c69 mina-sshd-api-common:2.12.0-90.v9f7fb_9fa_3d3b_ mina-sshd-api-core:2.12.0-90.v9f7fb_9fa_3d3b_ momentjs:1.1.1 monitoring:1.98.0 naginator:1.436.vb_e769dcb_cdf6 next-build-number:1.8 nodelabelparameter:1.12.0 pam-auth:1.10 parameter-separator:166.vd0120849b_386 parameterized-trigger:787.v665fcf2a_830b_ pipeline-agent-build-history:18.v66030db_e5f02 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-graph-view:224.vef989d141666 pipeline-groovy-lib:704.vc58b_8890a_384 pipeline-input-step:491.vb_07d21da_1a_fb_ pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2175.v76a_fff0a_2618 pipeline-model-definition:2.2175.v76a_fff0a_2618 pipeline-model-extensions:2.2175.v76a_fff0a_2618 pipeline-rest-api:2.34 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2175.v76a_fff0a_2618 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.2 plain-credentials:143.v1b_df8b_d3b_e48 plugin-util-api:4.1.0 popper2-api:2.11.6-4 postbuildscript:3.2.0-550.v88192b_d3e922 prism-api:1.29.0-13 prometheus:2.5.1 promoted-builds:945.v597f5c6a_d3fd rebuild:330.v645b_7df10e2a_ resource-disposer:0.23 robot:3.5.1 run-condition:1.7 saferestart:0.7 schedule-build:550.v8eb_e2fcf7b_1c scm-api:683.vb_16722fb_b_80b_ script-security:1326.vdb_c154de8669 sectioned-view:1.26 simple-theme-plugin:176.v39740c03a_a_f5 snakeyaml-api:2.2-111.vc6598e30cc65 ssh-credentials:308.ve4497b_ccd8f4 ssh-slaves:2.948.vb_8050d697fec ssh-steps:2.0.68.va_d21a_12a_6476 sshd:3.322.v159e91f6a_550 startup-trigger-plugin:2.9.4 structs:337.v1b_04ea_4df7c8 subversion:2.17.3 timestamper:1.26 token-macro:400.v35420b_922dcb_ trilead-api:2.133.vfb_8a_7b_9c5dd1 uno-choice:2.8.1 validating-string-parameter:183.v3748e79b_9737 variant:60.v7290fc0eb_b_cd view-job-filters:369.ve0513a_a_f5524 windows-slaves:1.8.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1291.v51fd2a_625da_7 workflow-basic-steps:1042.ve7b_140c4a_e0c workflow-cps:3867.v535458ce43fd workflow-durable-task-step:1331.vc8c2fed35334 workflow-job:1400.v7fd111b_ec82f workflow-multibranch:773.vc4fe1378f1d5 workflow-scm-step:415.v434365564324 workflow-step-api:657.v03b_e8115821b_ workflow-support:865.v43e78cc44e0d ws-cleanup:0.45 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux (Docker image jenkins/jenkins:2.440.1-lts-jdk21)

Reproduction steps

  1. Run a pipeline job
  2. Go to the job page
  3. Open "Extended Build History"

Expected Results

Extended Build History is displayed correctly.

Actual Results

An empty table is displayed with a red progress bar stuck indefinitely. In Jenkins logs is the following warning:

WARNING j.util.ProgressiveRendering$1#run: failed to compute /view/common/job/master-seed/extendedBuildHistory/
java.lang.ClassCastException: class org.jenkinsci.plugins.workflow.graph.FlowStartNode cannot be cast to class org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode (org.jenkinsci.plugins.workflow.graph.FlowStartNode is in unnamed module of loader jenkins.util.URLClassLoader2 @39ab304f; org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode is in unnamed module of loader jenkins.util.URLClassLoader2 @58a65306)
        at io.jenkins.plugins.agent_build_history.WorkflowJobTrend.calculate(WorkflowJobTrend.java:84)
        at io.jenkins.plugins.agent_build_history.WorkflowJobTrend.compute(WorkflowJobTrend.java:48)
        at jenkins.util.ProgressiveRendering$1.run(ProgressiveRendering.java:121)
        at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:67)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

Anything else?

Tested also on Java 17 based Docker image, same behaviour.

Are you interested in contributing a fix?

No response

mawinter69 commented 4 months ago

@Tiaxi Thanks for the report. Can you share more details about the job please? I'm not able to reproduce the problem. Does it happen as part of a branch source or organization folder job? Does it happen with an empty pipeline as well? From a failing job, can you look at the file flowNodeStore.xml should be in JENKINS_HOME/jobs/<jobname/builds/<buildnumber>/workflow-completed and share the entry for FlowStartNode. There should be exactly one such entry, e.g.

  <entry>
    <string>2</string>
    <Tag plugin="workflow-support@865.v43e78cc44e0d">
      <node class="org.jenkinsci.plugins.workflow.graph.FlowStartNode" plugin="workflow-api@1291.v51fd2a_625da_7">
        <parentIds/>
        <id>2</id>
      </node>
      <actions>
        <wf.a.TimingAction plugin="workflow-api@1291.v51fd2a_625da_7">
          <startTime>1708987987517</startTime>
        </wf.a.TimingAction>
      </actions>
    </Tag>
  </entry>
Tiaxi commented 4 months ago

First of all, thanks for creating this plugin, happy to help debugging. Frankly speaking, this functionality should be part of the Jenkins core.

Can you share more details about the job please? I'm not able to reproduce the problem. Does it happen as part of a branch source or organization folder job?

It's a regular declarative pipeline job. It loads a shared library with an explicit library statement at the top of the pipeline script. It's not part of a folder and not a multibranch pipeline. For the pipeline script fetching, lightweight checkout is unchecked. The whole pipeline is set to run on the same agent, in this case the built-in node with:

agent {
    label 'built-in'
}

Does it happen with an empty pipeline as well?

No. If there are no builds in the job, there is no warning in the logs.

`From a failing job, can you look at the file flowNodeStore.xml should be in JENKINS_HOME/jobs/<jobname/builds//workflow-completed and share the entry for FlowStartNode. There should be exactly one such entry, e.g.

There is a workflow folder inside the build folder, which has a flowNodeStore.xml:

  <entry>
    <string>2</string>
    <Tag plugin="workflow-support@865.v43e78cc44e0d">
      <node class="org.jenkinsci.plugins.workflow.graph.FlowStartNode" plugin="workflow-api@1291.v51fd2a_625da_7">
        <parentIds/>
        <id>2</id>
      </node>
      <actions>
        <s.a.WorkspaceActionImpl>
          <node></node>
          <path>/var/jenkins_home/workspace/master-seed@script/6707cdbc8a6d47aae849dc1b441f3ef6b534b5e7203ffed60e5f3b471da660c6</path>
          <labels class="sorted-set"/>
        </s.a.WorkspaceActionImpl>
        <wf.a.TimingAction plugin="workflow-api@1291.v51fd2a_625da_7">
          <startTime>1708989621702</startTime>
        </wf.a.TimingAction>
      </actions>
    </Tag>
  </entry>
Tiaxi commented 4 months ago

I narrowed the issue down to the SCM checkout. The failure starts to happen when the SCM checkout for the pipeline script is done with the lightweight checkout unchecked.

Once a build is run like that, the extended build history fails. Once I delete that build, it starts working again. If I modify the SCM checkout so that the lightweight checkout is checked and run again, the extended build history works for that build too.

mawinter69 commented 4 months ago

Thanks for the analysis. I could verify that this is the problem.

Frankly speaking, this functionality should be part of the Jenkins core.

To make that part of core would require adding several new apis in core and implement them in core and pipeline