Skip to content

Commit

Permalink
Merge pull request #9830 from MarkEWaite/stable-2.479-backport-1
Browse files Browse the repository at this point in the history
Backporting for 2.479.1
  • Loading branch information
basil authored Oct 6, 2024
2 parents 9b2f6c4 + ab2349a commit 7849dfb
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 7 deletions.
6 changes: 6 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ THE SOFTWARE.
<artifactId>stapler-groovy</artifactId>
<version>${stapler.version}</version>
</dependency>
<!-- Override the outdated managed dependency on asm in guice-parent -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.7</version>
</dependency>
<dependency>
<groupId>org.samba.jcifs</groupId>
<artifactId>jcifs</artifactId>
Expand Down
13 changes: 8 additions & 5 deletions core/src/main/java/hudson/model/UpdateSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,17 @@ public String getDownloadUrl() {

/**
* Is this the legacy default update center site?
* @deprecated
* Will be removed, currently returns always false.
* @since 2.343
* @since 1.357
*/
@Deprecated
@Restricted(NoExternalUse.class)
public boolean isLegacyDefault() {
return false;
return isJenkinsCI();
}

private boolean isJenkinsCI() {
return url != null
&& UpdateCenter.PREDEFINED_UPDATE_SITE_ID.equals(id)
&& url.startsWith("http://updates.jenkins-ci.org/");
}

/**
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/hudson/model/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -949,9 +949,28 @@ public void doRssLatest(StaplerRequest2 req, StaplerResponse2 rsp) throws IOExce

/**
* Accepts {@code config.xml} submission, as well as serve it.
*
* @since 2.475
*/
@WebMethod(name = "config.xml")
public HttpResponse doConfigDotXml(StaplerRequest2 req) throws IOException {
if (Util.isOverridden(View.class, getClass(), "doConfigDotXml", StaplerRequest.class)) {
return doConfigDotXml(StaplerRequest.fromStaplerRequest2(req));
} else {
return doConfigDotXmlImpl(req);
}
}

/**
* @deprecated use {@link #doConfigDotXml(StaplerRequest2)}
*/
@Deprecated
@StaplerNotDispatchable
public HttpResponse doConfigDotXml(StaplerRequest req) throws IOException {
return doConfigDotXmlImpl(StaplerRequest.toStaplerRequest2(req));
}

private HttpResponse doConfigDotXmlImpl(StaplerRequest2 req) throws IOException {
if (req.getMethod().equals("GET")) {
// read
checkPermission(READ);
Expand Down
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 @@ public String getShortDescription() {

@Override
protected int run() throws Exception {
Jenkins.get().doSafeRestart(null, message);
Jenkins.get().doSafeRestart((StaplerRequest2) null, message);
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 @@ public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, Servle
/**
* 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 @@ public HttpResponse doSafeRestart(StaplerRequest2 req, @QueryParameter("message"
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);
}
}

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
35 changes: 35 additions & 0 deletions test/src/test/java/hudson/model/UpdateCenterMigrationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package hudson.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;

public class UpdateCenterMigrationTest {

@Rule
public JenkinsRule j = new JenkinsRule() {
@Override
protected void configureUpdateCenter() {
// Avoid reverse proxy
DownloadService.neverUpdate = true;
UpdateSite.neverUpdate = true;
}
};

@Issue("JENKINS-73760")
@LocalData
@Test
public void updateCenterMigration() {
UpdateSite site = j.jenkins.getUpdateCenter().getSites().stream()
.filter(s -> UpdateCenter.PREDEFINED_UPDATE_SITE_ID.equals(s.getId()))
.findFirst()
.orElseThrow();
assertFalse(site.isLegacyDefault());
assertEquals(j.jenkins.getUpdateCenter().getDefaultBaseUrl() + "update-center.json", site.getUrl());
}
}
14 changes: 14 additions & 0 deletions test/src/test/java/hudson/model/UpdateSiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

public class UpdateSiteTest {
Expand Down Expand Up @@ -205,6 +206,19 @@ public void shutdownWebserver() throws Exception {
assertNotEquals("plugin data is present", Collections.emptyMap(), site.getData().plugins);
}

@Issue("JENKINS-73760")
@Test
public void isLegacyDefault() {
assertFalse("isLegacyDefault should be false with null id", new UpdateSite(null, "url").isLegacyDefault());
assertFalse(
"isLegacyDefault should be false when id is not default and url is http://updates.jenkins-ci.org/",
new UpdateSite("dummy", "http://updates.jenkins-ci.org/").isLegacyDefault());
assertTrue(
"isLegacyDefault should be true when id is default and url is http://updates.jenkins-ci.org/",
new UpdateSite(UpdateCenter.PREDEFINED_UPDATE_SITE_ID, "http://updates.jenkins-ci.org/").isLegacyDefault());
assertFalse("isLegacyDefault should be false with null url", new UpdateSite(null, null).isLegacyDefault());
}

@Test public void getAvailables() throws Exception {
UpdateSite site = getUpdateSite("/plugins/available-update-center.json");
List<UpdateSite.Plugin> available = site.getAvailables();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>http://updates.jenkins-ci.org/update-center.json</url>
</site>
</sites>
5 changes: 5 additions & 0 deletions war/src/main/scss/pages/_job.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@
font-weight: 450;
flex-grow: 1;
padding: 0.45rem 0 0;
word-break: normal;
overflow-wrap: anywhere;

.app-builds-container__item__time {
color: var(--text-color-secondary);
white-space: nowrap;
}
}

Expand Down Expand Up @@ -168,6 +171,8 @@
padding-left: 2.25rem;
margin-top: -2px;
grid-column: 1 / span 2;
word-break: normal;
overflow-wrap: anywhere;

&::before {
content: "";
Expand Down

0 comments on commit 7849dfb

Please sign in to comment.