-
-
Notifications
You must be signed in to change notification settings - Fork 60
Migrate from EE 8 to EE 9 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This plugin uses RequestImpl internals directly (casting StaplerRequest), which broke when Stapler was updated to EE 9 in jenkinsci/stapler#482. This change also updates dependencies to current versions where needed. The access modifier checker had to be disabled because this uses some Messages from the core.
| /** | ||
| * Returns the last build. | ||
| * | ||
| * @return the build or null | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the oldest build in the record. | ||
| * | ||
| * @return the build or null | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getFirstBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| Run run = job.getFirstBuild(); | ||
| if (run != null && (retVal == null || run.getTimestamp().before(retVal.getTimestamp()))) { | ||
| retVal = run; | ||
| } | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last successful build, if any. Otherwise null. A successful build would include | ||
| * either {@link Result#SUCCESS} or {@link Result#UNSTABLE}. | ||
| * | ||
| * @return the build or null | ||
| * @see #getLastStableBuild() | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastSuccessfulBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastSuccessfulBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last build that was anything but stable, if any. Otherwise null. | ||
| * | ||
| * @return the build or null | ||
| * @see #getLastSuccessfulBuild | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastUnsuccessfulBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastUnsuccessfulBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last unstable build, if any. Otherwise null. | ||
| * | ||
| * @return the build or null | ||
| * @see #getLastSuccessfulBuild | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastUnstableBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastUnstableBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last stable build, if any. Otherwise null. | ||
| * | ||
| * @return the build or null | ||
| * @see #getLastSuccessfulBuild | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastStableBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastStableBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last failed build, if any. Otherwise null. | ||
| * | ||
| * @return the build or null | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastFailedBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastFailedBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last completed build, if any. Otherwise null. | ||
| * | ||
| * @return the build or null | ||
| */ | ||
| @SuppressWarnings(UNUSED) | ||
| @CheckForNull | ||
| @Exported | ||
| public Run getLastCompletedBuild() { | ||
| Run retVal = null; | ||
| for (Job job : getAllJobs()) { | ||
| retVal = takeLast(retVal, job.getLastCompletedBuild()); | ||
| } | ||
| return retVal; | ||
| } | ||
|
|
||
| @CheckForNull | ||
| private Run takeLast(Run run1, Run run2) { | ||
| if (run2 != null && (run1 == null || run2.getTimestamp().after(run1.getTimestamp()))) { | ||
| return run2; | ||
| } | ||
| return run1; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that these methods aren't needed any more. They seem to be replaced with jenkinsci/cloudbees-folder-plugin#87. (They would at least require some changes to still build.)
basil
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This plugin uses RequestImpl internals directly (casting StaplerRequest), which broke when Stapler was updated to EE 9 in jenkinsci/stapler#482.
This change also updates dependencies to current versions where needed.
The access modifier checker had to be disabled because this uses some Messages from the core.
Testing done
Unit tests ran successfully.
I installed the locally built plugin in our Jenkins instance (running version 2.504.1) and was able to successfully update the job configuration of the jobs which are using this. This failed before with a ClassCastException in TemplateStaplerRequestWrapper.
Submitter checklist