Skip to content

Commit

Permalink
Merge branch 'master' into JENKINS-72009
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 authored Nov 12, 2023
2 parents 8fa24ca + 790f773 commit 5ceb1ad
Show file tree
Hide file tree
Showing 31 changed files with 196 additions and 330 deletions.
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,6 @@ THE SOFTWARE.
<artifactId>stapler-adjunct-codemirror</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-timeline</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-groovy</artifactId>
Expand Down
12 changes: 0 additions & 12 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,6 @@ THE SOFTWARE.
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-codemirror</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-timeline</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-groovy</artifactId>
Expand Down Expand Up @@ -495,14 +491,6 @@ THE SOFTWARE.
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- this helps us see the source code of the control while we edit Jenkins -->
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-timeline</artifactId>
<version>1.5</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
34 changes: 13 additions & 21 deletions core/src/main/java/hudson/model/BuildTimelineWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@

package hudson.model;

import hudson.Util;
import hudson.util.RunList;
import java.io.IOException;
import java.util.Date;
import java.util.ArrayList;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.koshuke.stapler.simile.timeline.Event;
import org.koshuke.stapler.simile.timeline.TimelineEventList;

/**
* UI widget for showing the SIMILE timeline control.
Expand All @@ -41,7 +40,9 @@
*
* @author Kohsuke Kawaguchi
* @since 1.372
* @deprecated since TODO
*/
@Deprecated
public class BuildTimelineWidget {
protected final RunList<?> builds;

Expand All @@ -59,22 +60,13 @@ public BuildTimelineWidget(RunList<?> builds) {
return builds.getLastBuild();
}

public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run<?, ?> r : builds.byTimestamp(min, max)) {
Event e = new Event();
e.start = new Date(r.getStartTimeInMillis());
e.end = new Date(r.getStartTimeInMillis() + r.getDuration());
// due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "&lt;" are transformed back to "<", but not the "&#60";
// to protect against XSS
e.title = Util.escape(r.getFullDisplayName()).replace("&lt;", "&#60;");
e.link = req.getContextPath() + '/' + r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X", c.getBaseColor().darker().getRGB() & 0xFFFFFF);
e.classname = "event-" + c.noAnime().toString() + " " + (c.isAnimated() ? "animated" : "");
result.add(e);
}
return result;
public HttpResponse doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) {
return (req1, rsp, node) -> {
JSONObject o = new JSONObject();
o.put("events", JSONArray.fromObject(new ArrayList<>()));
rsp.setContentType("application/javascript;charset=UTF-8");
o.write(rsp.getWriter());
};
}

}
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ public LoadStatistics getLoadStatistics() {
return LabelAtom.get(nodeName != null ? nodeName : Jenkins.get().getSelfLabel().toString()).loadStatistics;
}

@Deprecated
@Restricted(DoNotUse.class)
public BuildTimelineWidget getTimeline() {
return new BuildTimelineWidget(getBuilds());
}
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import org.jfree.ui.RectangleInsets;
import org.jvnet.localizer.Localizable;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
Expand Down Expand Up @@ -1597,6 +1598,8 @@ public ACL getACL() {
return Jenkins.get().getAuthorizationStrategy().getACL(this);
}

@Deprecated
@Restricted(DoNotUse.class)
public BuildTimelineWidget getTimeline() {
return new BuildTimelineWidget(getBuilds());
}
Expand Down
44 changes: 0 additions & 44 deletions core/src/main/java/hudson/model/UserProperties.java

This file was deleted.

2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,8 @@ public RunList getBuilds() {
return new RunList(this);
}

@Deprecated
@Restricted(DoNotUse.class)
public BuildTimelineWidget getTimeline() {
return new BuildTimelineWidget(getBuilds());
}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/hudson/model/queue/FutureImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,8 @@ public synchronized void setAsCancelled() {
synchronized void addExecutor(@NonNull Executor executor) {
this.executors.add(executor);
}

synchronized void finished() {
executors.clear();
}
}
1 change: 1 addition & 0 deletions core/src/main/java/hudson/model/queue/WorkUnitContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void synchronizeEnd(Executor e, Queue.Executable executable, Throwable pr
}
}
}
future.finished();
}
}
}
Expand Down
56 changes: 56 additions & 0 deletions core/src/main/java/hudson/slaves/JNLPLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package hudson.slaves;

import com.google.common.escape.Escaper;
import com.google.common.escape.Escapers;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand All @@ -38,6 +40,7 @@
import jenkins.slaves.RemotingWorkDirSettings;
import jenkins.util.SystemProperties;
import jenkins.websocket.WebSockets;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -195,6 +198,59 @@ public void launch(SlaveComputer computer, TaskListener listener) {
@Restricted(NoExternalUse.class)
public static /*almost final*/ Descriptor<ComputerLauncher> DESCRIPTOR;

@NonNull
@Restricted(NoExternalUse.class)
public String getRemotingOptionsUnix(@NonNull Computer computer) {
return getRemotingOptions(escapeUnix(computer.getName()));
}

@NonNull
@Restricted(NoExternalUse.class)
public String getRemotingOptionsWindows(@NonNull Computer computer) {
return getRemotingOptions(escapeWindows(computer.getName()));
}

private String getRemotingOptions(String computerName) {
StringBuilder sb = new StringBuilder();
sb.append("-name ");
sb.append(computerName);
sb.append(' ');
if (isWebSocket()) {
sb.append("-webSocket ");
}
if (tunnel != null) {
sb.append(" -tunnel ");
sb.append(tunnel);
sb.append(' ');
}
return sb.toString();
}

/**
* {@link Jenkins#checkGoodName(String)} saves us from most troublesome characters, but we still have to deal with
* spaces and therefore with double quotes and backticks.
*/
private static String escapeUnix(String input) {
if (StringUtils.isAlphanumeric(input)) {
return input;
}
Escaper escaper =
Escapers.builder().addEscape('"', "\\\"").addEscape('`', "\\`").build();
return "\"" + escaper.escape(input) + "\"";
}

/**
* {@link Jenkins#checkGoodName(String)} saves us from most troublesome characters, but we still have to deal with
* spaces and therefore with double quotes.
*/
private static String escapeWindows(String input) {
if (StringUtils.isAlphanumeric(input)) {
return input;
}
Escaper escaper = Escapers.builder().addEscape('"', "\\\"").build();
return "\"" + escaper.escape(input) + "\"";
}

/**
* Gets work directory options as a String.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/slaves/SlaveComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ protected Future<?> _connect(boolean forceReconnect) {
e.addSuppressed(threadInfo);
Functions.printStackTrace(e, taskListener.error(Messages.ComputerLauncher_abortedLaunch()));
throw e;
} catch (RuntimeException e) {
} catch (RuntimeException | Error e) {
e.addSuppressed(threadInfo);
Functions.printStackTrace(e, taskListener.error(Messages.ComputerLauncher_unexpectedError()));
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static String getId() {

@Override
public boolean isActivated() {
return !disabled && getDeprecationPeriod().toTotalMonths() < 18;
return !disabled && getDeprecationPeriod().toTotalMonths() < 12;
}

@Override
Expand Down Expand Up @@ -156,7 +156,7 @@ private static Period getDeprecationPeriod() {

@NonNull
private static Severity getSeverity() {
return getDeprecationPeriod().toTotalMonths() < 9 ? Severity.DANGER : Severity.WARNING;
return getDeprecationPeriod().toTotalMonths() < 3 ? Severity.DANGER : Severity.WARNING;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
DescribeRename=Renommer {0} {1}
NewName=Nouveau nom
Rename=Renommer
Loading

0 comments on commit 5ceb1ad

Please sign in to comment.