Skip to content

Commit

Permalink
Merge branch 'master' into improve-user-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik authored Sep 11, 2024
2 parents 2292b9b + 65f374c commit 1953409
Show file tree
Hide file tree
Showing 30 changed files with 595 additions and 275 deletions.
20 changes: 7 additions & 13 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import hudson.model.ParameterDefinition;
import hudson.model.ParameterDefinition.ParameterDescriptor;
import hudson.model.PasswordParameterDefinition;
import hudson.model.Queue;
import hudson.model.Run;
import hudson.model.Slave;
import hudson.model.TimeZoneProperty;
Expand Down Expand Up @@ -157,6 +156,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import jenkins.console.ConsoleUrlProvider;
import jenkins.console.WithConsoleUrl;
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
import jenkins.model.Jenkins;
Expand Down Expand Up @@ -1981,20 +1981,14 @@ public static String joinPath(String... components) {
}

/**
* Computes the link to the console for the run for the specified executable, taking {@link ConsoleUrlProvider} into account.
* @param executable the executable (normally a {@link Run})
* @return the absolute URL for accessing the build console for the executable, or null if there is no build associated with the executable
* Computes the link to the console for the run for the specified object, taking {@link ConsoleUrlProvider} into account.
* @param withConsoleUrl the object to compute a console url for (can be {@link Run}, a {@code PlaceholderExecutable}...)
* @return the absolute URL for accessing the build console for the given object, or null if there is no console URL defined for the object.
* @since 2.433
*/
public static @CheckForNull String getConsoleUrl(Queue.Executable executable) {
if (executable == null) {
return null;
} else if (executable instanceof Run) {
return ConsoleUrlProvider.getRedirectUrl((Run<?, ?>) executable);
} else {
// Handles cases such as PlaceholderExecutable for Pipeline node steps.
return getConsoleUrl(executable.getParentExecutable());
}
public static @CheckForNull String getConsoleUrl(WithConsoleUrl withConsoleUrl) {
String consoleUrl = withConsoleUrl.getConsoleUrl();
return consoleUrl != null ? Stapler.getCurrentRequest().getContextPath() + '/' + consoleUrl : null;
}

/**
Expand Down
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 @@ -1102,6 +1102,8 @@ protected void removeExecutor(final Executor e) {
if (ciBase != null) { // TODO confirm safe to assume non-null and use getInstance()
ciBase.removeComputer(Computer.this);
}
} else if (isIdle()) {
threadPoolForRemoting.submit(() -> Listeners.notify(ComputerListener.class, false, l -> l.onIdle(this)));
}
}
};
Expand Down
9 changes: 5 additions & 4 deletions core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import jenkins.model.BuildDiscarder;
import jenkins.model.BuildDiscarderProperty;
import jenkins.model.DirectlyModifiableTopLevelItemGroup;
import jenkins.model.HistoricalBuild;
import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
import jenkins.model.ModelObjectWithChildren;
Expand Down Expand Up @@ -636,9 +637,9 @@ protected HistoryWidget createHistoryWidget() {
throw new IllegalStateException("HistoryWidget is now created via WidgetFactory implementation");
}

public static final HistoryWidget.Adapter<Run> HISTORY_ADAPTER = new Adapter<>() {
public static final HistoryWidget.Adapter<HistoricalBuild> HISTORY_ADAPTER = new Adapter<>() {
@Override
public int compare(Run record, String key) {
public int compare(HistoricalBuild record, String key) {
try {
int k = Integer.parseInt(key);
return record.getNumber() - k;
Expand All @@ -648,12 +649,12 @@ public int compare(Run record, String key) {
}

@Override
public String getKey(Run record) {
public String getKey(HistoricalBuild record) {
return String.valueOf(record.getNumber());
}

@Override
public boolean isBuilding(Run record) {
public boolean isBuilding(HistoricalBuild record) {
return record.isBuilding();
}

Expand Down
13 changes: 12 additions & 1 deletion core/src/main/java/hudson/model/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import jenkins.console.WithConsoleUrl;
import jenkins.model.Jenkins;
import jenkins.model.queue.AsynchronousExecution;
import jenkins.model.queue.CompositeCauseOfBlockage;
Expand Down Expand Up @@ -2088,7 +2089,7 @@ default Collection<? extends SubTask> getSubTasks() {
* used to render the HTML that indicates this executable is executing.
*/
@StaplerAccessibleType
public interface Executable extends Runnable {
public interface Executable extends Runnable, WithConsoleUrl {
/**
* Task from which this executable was created.
*
Expand Down Expand Up @@ -2131,6 +2132,16 @@ default long getEstimatedDuration() {
return Executables.getParentOf(this).getEstimatedDuration();
}

/**
* Handles cases such as {@code PlaceholderExecutable} for Pipeline node steps.
* @return by default, that of {@link #getParentExecutable} if defined
*/
@Override
default String getConsoleUrl() {
Executable parent = getParentExecutable();
return parent != null ? parent.getConsoleUrl() : null;
}

/**
* Used to render the HTML. Should be a human readable text of what this executable is.
*/
Expand Down
Loading

0 comments on commit 1953409

Please sign in to comment.