Skip to content
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

[JENKINS-73838] Compatibility for Jenkins#doSafeRestart(StaplerRequest, String) #9797

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/java/jenkins/cli/SafeRestartCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.args4j.Option;
import org.kohsuke.stapler.StaplerRequest2;

/**
* Safe Restart Jenkins - do not accept any new jobs and try to pause existing.
Expand All @@ -53,7 +54,7 @@

@Override
protected int run() throws Exception {
Jenkins.get().doSafeRestart(null, message);
Jenkins.get().doSafeRestart((StaplerRequest2) null, message);

Check warning on line 57 in core/src/main/java/jenkins/cli/SafeRestartCommand.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 57 is not covered by tests
return 0;
}
}
16 changes: 15 additions & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4665,7 +4665,7 @@
/**
* Queues up a safe restart of Jenkins. Jobs have to finish or pause before it can proceed. No new jobs are accepted.
*
* @since 2.414
* @since 2.475
*/
public HttpResponse doSafeRestart(StaplerRequest2 req, @QueryParameter("message") String message) throws IOException, ServletException, RestartNotSupportedException {
checkPermission(MANAGE);
Expand All @@ -4684,6 +4684,20 @@
return HttpResponses.redirectToDot();
}

/**
* @deprecated use {@link #doSafeRestart(StaplerRequest2, String)}
* @since 2.414
*/
@Deprecated
@StaplerNotDispatchable
public HttpResponse doSafeRestart(StaplerRequest req, @QueryParameter("message") String message) throws IOException, javax.servlet.ServletException, RestartNotSupportedException {
try {
return doSafeRestart(StaplerRequest.toStaplerRequest2(req), message);
} catch (ServletException e) {
throw ServletExceptionWrapper.fromJakartaServletException(e);

Check warning on line 4697 in core/src/main/java/jenkins/model/Jenkins.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 4695-4697 are not covered by tests
}
}

private static Lifecycle restartableLifecycle() throws RestartNotSupportedException {
if (Main.isUnitTest) {
throw new RestartNotSupportedException("Restarting the controller JVM is not supported in JenkinsRule-based tests");
Expand Down
Loading