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

Last changes history becomes empty after Jenkins restart

      After a restart the Last changes history becomes empty. This is explained by following comment on JENKINS-49368:

      https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5 will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().

       

      getLastChangesBuilds() is what we use to create the history page.

      Note that after a job run the history is restored.

          [JENKINS-50116] Last changes history becomes empty after Jenkins restart

          Rafael Pestano created issue -
          Rafael Pestano made changes -
          Description Original: As comented on JENKINS-45892:
          https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5 will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          New: As comented on JENKINS-49368:
          https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5 will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          Rafael Pestano made changes -
          Description Original: As comented on JENKINS-49368:
          https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5 will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          New: After a restart the [Last changes history|https://wiki.jenkins.io/display/JENKINS/Last+Changes+Plugin#LastChangesPlugin-Buildchangeshistory] becomes empty. This is explained by following comment on JENKINS-49368:
          {quote}
           [https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5] will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          {quote}
           

          getLastChangesBuilds() is what we use to create the history page.
          Rafael Pestano made changes -
          Description Original: After a restart the [Last changes history|https://wiki.jenkins.io/display/JENKINS/Last+Changes+Plugin#LastChangesPlugin-Buildchangeshistory] becomes empty. This is explained by following comment on JENKINS-49368:
          {quote}
           [https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5] will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          {quote}
           

          getLastChangesBuilds() is what we use to create the history page.
          New: After a restart the [Last changes history|https://wiki.jenkins.io/display/JENKINS/Last+Changes+Plugin#LastChangesPlugin-Buildchangeshistory] becomes empty. This is explained by following comment on JENKINS-49368:
          {quote}[https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5] will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          {quote}
           

          [getLastChangesBuilds()|https://github.com/jenkinsci/last-changes-plugin/blob/2e0f1c1c58d7a1ccda8118f98d874951a4dab7f6/src/main/resources/com/github/jenkins/lastchanges/LastChangesProjectAction/index.jelly#L15] is what we use to create the history page.
          Rafael Pestano made changes -
          Description Original: After a restart the [Last changes history|https://wiki.jenkins.io/display/JENKINS/Last+Changes+Plugin#LastChangesPlugin-Buildchangeshistory] becomes empty. This is explained by following comment on JENKINS-49368:
          {quote}[https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5] will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          {quote}
           

          [getLastChangesBuilds()|https://github.com/jenkinsci/last-changes-plugin/blob/2e0f1c1c58d7a1ccda8118f98d874951a4dab7f6/src/main/resources/com/github/jenkins/lastchanges/LastChangesProjectAction/index.jelly#L15] is what we use to create the history page.
          New: After a restart the [Last changes history|https://wiki.jenkins.io/display/JENKINS/Last+Changes+Plugin#LastChangesPlugin-Buildchangeshistory] becomes empty. This is explained by following comment on JENKINS-49368:
          {quote}[https://github.com/jenkinsci/last-changes-plugin/commit/0cb6083a31b207099c5400e4f4a93bee8510f3a5] will not work correctly after the Jenkins restart. The class has no readResolve() resolution, so the value will be null when you save new jobs and reload them from the disk. It will cause NPEs in methods like getLastChangesBuilds().
          {quote}
           

          [getLastChangesBuilds()|https://github.com/jenkinsci/last-changes-plugin/blob/2e0f1c1c58d7a1ccda8118f98d874951a4dab7f6/src/main/resources/com/github/jenkins/lastchanges/LastChangesProjectAction/index.jelly#L15] is what we use to create the history page.

          Note that after a job run the history is restored.

          Rafael Pestano added a comment - - edited

          Hi oleg_nenashev,

          For fixing JENKINS-49368 we had to make the job instance variable transient and now users are facing an NPE as you predicted.

          You've suggested:

          I would actually suggest modifying getJob() to restore the field if null and then switch all the code to using this method instead of the direct field access. Your mileage may vary

          Can you point me to an example on how I could achieve that? I've read https://wiki.jenkins.io/display/JENKINS/Hint+on+retaining+backward+compatibility but could not figure it out on how I would change getJob() in order to restore it.

          Thanks in advance!

          Rafael Pestano added a comment - - edited Hi oleg_nenashev , For fixing JENKINS-49368 we had to make the job instance variable transient and now users are facing an NPE as you predicted. You've suggested: I would actually suggest modifying getJob() to restore the field if null and then switch all the code to using this method instead of the direct field access. Your mileage may vary Can you point me to an example on how I could achieve that? I've read https://wiki.jenkins.io/display/JENKINS/Hint+on+retaining+backward+compatibility but could not figure it out on how I would change getJob() in order to restore it. Thanks in advance!

          Daniel Beck added a comment -

          The project action looks like it should be created in a https://javadoc.jenkins.io/jenkins/model/TransientActionFactory.html for the appropriate job type (AbstractProject) rather than stored with the job.

          It could be attached to any project, and getIcon overloaded to only show when one of the newest N builds has an Action attached. This would be more efficient than always traversing all builds.

          Daniel Beck added a comment - The project action looks like it should be created in a https://javadoc.jenkins.io/jenkins/model/TransientActionFactory.html for the appropriate job type (AbstractProject) rather than stored with the job. It could be attached to any project, and getIcon overloaded to only show when one of the newest N builds has an Action attached. This would be more efficient than always traversing all builds.

          Hi danielbeck, thank you very much for the hint. Do you have any docs or sample project using TransientActionFactory?

           

          As an example I've found github plugin link action and they use the concept of job property, see here. Do I need it?  When/how the action is stored on the factory? 

           

           

          Rafael Pestano added a comment - Hi danielbeck , thank you very much for the hint. Do you have any docs or sample project using TransientActionFactory?   As an example I've found github plugin link action and they use the concept of job property, see here . Do I need it?  When/how the action is stored on the factory?     

          Daniel Beck added a comment -

          There's no need to store the project-level action. It can be transient, hence the name.

          https://jenkins.io/doc/developer/extensions/jenkins-core/#transientactionfactory might help.

          Daniel Beck added a comment - There's no need to store the project-level action. It can be transient, hence the name. https://jenkins.io/doc/developer/extensions/jenkins-core/#transientactionfactory might help.
          Rafael Pestano made changes -
          Attachment New: last-changes-icons.png [ 43950 ]

            rmpestano Rafael Pestano
            rmpestano Rafael Pestano
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: