Skip to content

Commit

Permalink
Merge branch 'master' into new-copy-button
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Jan 9, 2025
2 parents 4617883 + a49c83c commit 37082db
Show file tree
Hide file tree
Showing 20 changed files with 313 additions and 146 deletions.
17 changes: 11 additions & 6 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ THE SOFTWARE.
<commons-fileupload2.version>2.0.0-M2</commons-fileupload2.version>
<groovy.version>2.4.21</groovy.version>
<jelly.version>1.1-jenkins-20250108</jelly.version>
<stapler.version>1940.v41211a_a_b_b_d8b_</stapler.version>
<stapler.version>1942.v708e07325402</stapler.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -132,11 +132,6 @@ THE SOFTWARE.
<artifactId>commons-io</artifactId>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-xml</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down Expand Up @@ -243,11 +238,21 @@ THE SOFTWARE.
<artifactId>annotation-indexer</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jelly</artifactId>
<version>${jelly.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jelly-tags-fmt</artifactId>
<version>${jelly.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jelly-tags-xml</artifactId>
<version>${jelly.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jexl</artifactId>
Expand Down
48 changes: 14 additions & 34 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,40 +166,6 @@ THE SOFTWARE.
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-xml</artifactId>
<exclusions>
<exclusion>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly</artifactId>
</exclusion>
<exclusion>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-junit</artifactId>
</exclusion>
<exclusion>
<groupId>commons-jexl</groupId>
<artifactId>commons-jexl</artifactId>
</exclusion>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- Jenkins doesn't use this directly, but some plugins wanted to use the latest -->
<groupId>commons-lang</groupId>
Expand Down Expand Up @@ -310,6 +276,20 @@ THE SOFTWARE.
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jelly-tags-fmt</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jelly-tags-xml</artifactId>
<exclusions>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
<exclusion>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>commons-jexl</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;
import java.util.TimeZone;
Expand All @@ -158,6 +159,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import jenkins.console.ConsoleUrlProvider;
import jenkins.console.DefaultConsoleUrlProvider;
import jenkins.console.WithConsoleUrl;
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
Expand Down Expand Up @@ -1993,6 +1995,14 @@ public static String joinPath(String... components) {
return consoleUrl != null ? Stapler.getCurrentRequest().getContextPath() + '/' + consoleUrl : null;
}

/**
* @param run the run
* @return the Console Provider for the given run, if null, the default Console Provider
*/
public static ConsoleUrlProvider getConsoleProviderFor(Run<?, ?> run) {
return Optional.ofNullable(ConsoleUrlProvider.getProvider(run)).orElse(new DefaultConsoleUrlProvider());

Check warning on line 2003 in core/src/main/java/hudson/Functions.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 2003 is not covered by tests
}

/**
* Escapes the character unsafe for e-mail address.
* See <a href="https://en.wikipedia.org/wiki/Email_address">the Wikipedia page</a> for the details,
Expand Down
21 changes: 1 addition & 20 deletions core/src/main/java/hudson/cli/CLICommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
import java.util.logging.Logger;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.apache.commons.discovery.ResourceClassIterator;
import org.apache.commons.discovery.ResourceNameIterator;
import org.apache.commons.discovery.resource.ClassLoaders;
import org.apache.commons.discovery.resource.classes.DiscoverClasses;
import org.apache.commons.discovery.resource.names.DiscoverServiceNames;
import org.jvnet.hudson.annotation_indexer.Index;
import org.jvnet.tiger_types.Types;
import org.kohsuke.accmod.Restricted;
Expand Down Expand Up @@ -566,27 +561,13 @@ public static CLICommand getCurrent() {
if (j != null) { // only when running on the controller
// Register OptionHandlers through META-INF/services/annotations and Annotation Indexer
try {
for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.get().pluginManager.uberClassLoader, Class.class)) {
for (Class c : Index.list(OptionHandlerExtension.class, j.getPluginManager().uberClassLoader, Class.class)) {
Type t = Types.getBaseClass(c, OptionHandler.class);
CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t, 0)), c);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}

// Register OptionHandlers through META-INF/services and Commons Discovery
ClassLoaders cls = new ClassLoaders();
cls.put(j.getPluginManager().uberClassLoader);
ResourceNameIterator servicesIter =
new DiscoverServiceNames(cls).findResourceNames(OptionHandler.class.getName());
final ResourceClassIterator itr =
new DiscoverClasses(cls).findResourceClasses(servicesIter);

while (itr.hasNext()) {
Class h = itr.nextResourceClass().loadClass();
Class c = Types.erasure(Types.getTypeArgument(Types.getBaseClass(h, OptionHandler.class), 0));
CmdLineParser.registerHandler(c, h);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/**
* Refers to an {@link Item} by its name.
* May be subclassed to handle specific kinds of items.
* (Use {@code @MetaInfServices(OptionHandler.class)} to register the subclass.)
* (Use {@code @OptionHandlerExtension} to register the subclass.)
* @param <T> the kind of item being handled
* @since 1.538
*/
Expand Down
20 changes: 14 additions & 6 deletions core/src/main/java/jenkins/console/ConsoleUrlProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ default Descriptor<ConsoleUrlProvider> getDescriptor() {
return Stapler.getCurrentRequest().getContextPath() + '/' + run.getConsoleUrl();
}

/**
* Looks up the {@link #getConsoleUrl} value from the first provider to offer one.
* @since 2.476
*/
static @NonNull String consoleUrlOf(Run<?, ?> run) {
static List<ConsoleUrlProvider> all() {
final List<ConsoleUrlProvider> providers = new ArrayList<>();
User currentUser = User.current();
if (currentUser != null) {
Expand All @@ -105,8 +101,20 @@ default Descriptor<ConsoleUrlProvider> getDescriptor() {
if (globalProviders != null) {
providers.addAll(globalProviders);
}
return providers;
}

static ConsoleUrlProvider getProvider(Run<?, ?> run) {
return all().stream().filter(provider -> provider.getConsoleUrl(run) != null).findFirst().orElse(null);

Check warning on line 108 in core/src/main/java/jenkins/console/ConsoleUrlProvider.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 108 is not covered by tests
}

/**
* Looks up the {@link #getConsoleUrl} value from the first provider to offer one.
* @since 2.476
*/
static @NonNull String consoleUrlOf(Run<?, ?> run) {
String url = null;
for (ConsoleUrlProvider provider : providers) {
for (ConsoleUrlProvider provider : all()) {
try {
String tempUrl = provider.getConsoleUrl(run);
if (tempUrl != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* The MIT License
*
* Copyright (c) 2025, Jan Faracik
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package jenkins.model.experimentalflags;

import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Extension;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

@Extension
@Restricted(NoExternalUse.class)
public class NewBuildPageUserExperimentalFlag extends BooleanUserExperimentalFlag {
public NewBuildPageUserExperimentalFlag() {
super("new-build-page.flag");
}

@Override
public String getDisplayName() {
return "New build page";
}

@Nullable
@Override
public String getShortDescription() {
return "Enables a revamped build page. This feature is still a work in progress, so some things might not work perfectly yet.";

Check warning on line 47 in core/src/main/java/jenkins/model/experimentalflags/NewBuildPageUserExperimentalFlag.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 41-47 are not covered by tests
}
}
38 changes: 38 additions & 0 deletions core/src/main/resources/hudson/model/Run/console-log.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:t="/lib/hudson">
<j:set var="threshold" value="${h.getSystemProperty('hudson.consoleTailKB')?:'150'}" />
<!-- Show at most last 150KB (can override with system property) unless consoleFull is set -->
<j:set var="offset" value="${empty(consoleFull) ? it.logText.length()-threshold*1024 : 0}" />
<j:choose>
<j:when test="${offset > 0}">
<a class="jenkins-button jenkins-!-accent-color jenkins-!-padding-2 jenkins-!-margin-bottom-2" style="width: 100%; justify-content: start" href="consoleFull">
<l:icon src="symbol-help-circle" />
${%skipSome(offset / 1024)}
</a>
</j:when>
<j:otherwise>
<j:set var="offset" value="${0}" />
</j:otherwise>
</j:choose>

<j:out value="${h.generateConsoleAnnotationScriptAndStylesheet()}"/>

<j:choose>
<!-- Do progressive console output -->
<j:when test="${it.isLogUpdated()}">
<pre id="out" class="console-output" />
<div id="spinner">
<l:progressAnimation/>
</div>
<t:progressiveText href="logText/progressiveHtml" idref="out" spinner="spinner"
startOffset="${offset}" onFinishEvent="jenkins:consoleFinished"/>
</j:when>
<!-- output is completed now. -->
<j:otherwise>
<pre class="console-output">
<st:getOutput var="output" />
<j:whitespace>${it.writeLogTo(offset,output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
skipSome=This log is too long to show here, {0,number,integer} KB has been skipped — click to see the complete log
33 changes: 1 addition & 32 deletions core/src/main/resources/hudson/model/Run/console.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,7 @@ THE SOFTWARE.
${%Console Output}
</t:buildCaption>

<j:set var="threshold" value="${h.getSystemProperty('hudson.consoleTailKB')?:'150'}" />
<!-- Show at most last 150KB (can override with system property) unless consoleFull is set -->
<j:set var="offset" value="${empty(consoleFull) ? it.logText.length()-threshold*1024 : 0}" />
<j:choose>
<j:when test="${offset > 0}">
${%skipSome(offset/1024,"consoleFull")}
</j:when>
<j:otherwise>
<j:set var="offset" value="${0}" />
</j:otherwise>
</j:choose>

<j:out value="${h.generateConsoleAnnotationScriptAndStylesheet()}"/>

<j:choose>
<!-- Do progressive console output -->
<j:when test="${it.isLogUpdated()}">
<pre id="out" class="console-output" />
<div id="spinner">
<l:progressAnimation/>
</div>
<t:progressiveText href="logText/progressiveHtml" idref="out" spinner="spinner"
startOffset="${offset}" onFinishEvent="jenkins:consoleFinished"/>
</j:when>
<!-- output is completed now. -->
<j:otherwise>
<pre class="console-output" id="out">
<st:getOutput var="output" />
<j:whitespace>${it.writeLogTo(offset,output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
<st:include page="console-log.jelly" />
</l:main-panel>
</l:layout>
</j:jelly>
Loading

0 comments on commit 37082db

Please sign in to comment.