Skip to content

Commit

Permalink
Merge branch 'master' into new-reorderable-list
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Dec 13, 2024
2 parents ad341fb + 7020e80 commit 7d25b30
Show file tree
Hide file tree
Showing 217 changed files with 3,400 additions and 2,799 deletions.
10 changes: 0 additions & 10 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@
"org.fusesource.jansi:jansi"
]
},
{
"description": "Depends on commons-lang3 which is in progress for removal from core. See: https://issues.jenkins.io/browse/JENKINS-73355",
"matchManagers": [
"maven"
],
"enabled": false,
"matchPackageNames": [
"org.apache.commons:commons-compress"
]
},
{
"description": "Contains incompatible API changes and needs compatibility work. See: https://github.com/jenkinsci/jenkins/pull/4224",
"matchManagers": [
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish-release-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
wget -q https://get.jenkins.io/${REPO}/${PROJECT_VERSION}/${FILE_NAME}
- name: Upload Release Asset
id: upload-war
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Upload Release Asset
id: upload-deb
if: always()
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
- name: Upload Release Asset
id: upload-rpm
if: always()
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
- name: Upload Release Asset
id: upload-msi
if: always()
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:
- name: Upload Release Asset
id: upload-suse-rpm
if: always()
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion ath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o xtrace
cd "$(dirname "$0")"

# https://github.com/jenkinsci/acceptance-test-harness/releases
export ATH_VERSION=6040.v72ed2f5b_59f6
export ATH_VERSION=6107.v8c73fa_b_8f784

if [[ $# -eq 0 ]]; then
export JDK=17
Expand Down
19 changes: 7 additions & 12 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ THE SOFTWARE.

<properties>
<commons-fileupload2.version>2.0.0-M2</commons-fileupload2.version>
<stapler.version>1903.v994a_db_314d58</stapler.version>
<stapler.version>1928.v9115fe47607f</stapler.version>
<groovy.version>2.4.21</groovy.version>
</properties>

Expand All @@ -62,15 +62,15 @@ THE SOFTWARE.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>6.1.14</version>
<version>6.2.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- https://docs.spring.io/spring-security/reference/6.3/getting-spring-security.html#getting-maven-no-boot -->
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-bom</artifactId>
<version>6.3.4</version>
<version>6.4.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -109,7 +109,7 @@ THE SOFTWARE.
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.20</version>
<version>1.4.21</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
Expand All @@ -129,7 +129,7 @@ THE SOFTWARE.
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.17.0</version>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
Expand Down Expand Up @@ -191,11 +191,6 @@ THE SOFTWARE.
<artifactId>ant</artifactId>
<version>1.10.15</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2</artifactId>
Expand Down Expand Up @@ -295,7 +290,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jvnet.hudson</groupId>
<artifactId>commons-jelly-tags-define</artifactId>
<version>1.1-jenkins-20240903</version>
<version>1.1-jenkins-20241115</version>
</dependency>
<dependency>
<groupId>org.jvnet.localizer</groupId>
Expand Down Expand Up @@ -335,7 +330,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>json-lib</artifactId>
<version>2.4-jenkins-7</version>
<version>2.4-jenkins-8</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
Expand Down
11 changes: 0 additions & 11 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,6 @@ THE SOFTWARE.
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<exclusions>
<!-- Only needed for Pack200UnpackerAdapter, which we do not use -->
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-core</artifactId>
Expand Down
27 changes: 3 additions & 24 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import jenkins.MasterToSlaveFileCallable;
import jenkins.SlaveToMasterFileCallable;
import jenkins.agents.ControllerToAgentFileCallable;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import jenkins.util.ContextResettingExecutorService;
Expand Down Expand Up @@ -520,30 +520,14 @@ public int archive(final ArchiverFactory factory, OutputStream os, final DirScan
return act(new Archive(factory, out, scanner, verificationRoot, openOptions));
}

private static class Archive extends MasterToSlaveFileCallable<Integer> {
private final ArchiverFactory factory;
private final OutputStream out;
private final DirScanner scanner;
private final String verificationRoot;
private OpenOption[] openOptions;

Archive(ArchiverFactory factory, OutputStream out, DirScanner scanner, String verificationRoot, OpenOption... openOptions) {
this.factory = factory;
this.out = out;
this.scanner = scanner;
this.verificationRoot = verificationRoot;
this.openOptions = openOptions;
}

private record Archive(ArchiverFactory factory, OutputStream out, DirScanner scanner, String verificationRoot, OpenOption... openOptions) implements ControllerToAgentFileCallable<Integer> {
@Override
public Integer invoke(File f, VirtualChannel channel) throws IOException {
try (Archiver a = factory.create(out)) {
scanner.scan(f, ignoringTmpDirs(ignoringSymlinks(a, verificationRoot, openOptions), verificationRoot, openOptions));
return a.countEntries();
}
}

private static final long serialVersionUID = 1L;
}

public int archive(final ArchiverFactory factory, OutputStream os, final FileFilter filter) throws IOException, InterruptedException {
Expand Down Expand Up @@ -1185,12 +1169,7 @@ public void copyFrom(org.apache.commons.fileupload.FileItem file) throws IOExcep
/**
* Code that gets executed on the machine where the {@link FilePath} is local.
* Used to act on {@link FilePath}.
* <strong>Warning:</strong> implementations must be serializable, so prefer a static nested class to an inner class.
*
* <p>
* Subtypes would likely want to extend from either {@link MasterToSlaveCallable}
* or {@link SlaveToMasterFileCallable}.
*
* A typical implementation would be a {@code record} implementing {@link ControllerToAgentFileCallable}.
* @see FilePath#act(FileCallable)
*/
public interface FileCallable<T> extends Serializable, RoleSensitive {
Expand Down
32 changes: 32 additions & 0 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import hudson.model.View;
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import hudson.search.SearchFactory;
import hudson.search.SearchableModelObject;
import hudson.security.ACL;
import hudson.security.AccessControlled;
Expand Down Expand Up @@ -124,6 +125,7 @@
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -2576,4 +2578,34 @@ static String guessIcon(String iconGuess, String rootURL) {
public static String generateItemId() {
return String.valueOf(Math.floor(Math.random() * 3000));
}

@Restricted(NoExternalUse.class)
public static ExtensionList<SearchFactory> getSearchFactories() {
return SearchFactory.all();
}

/**
* @param keyboardShortcut the shortcut to be translated
* @return the translated shortcut, e.g. CMD+K to ⌘+K for macOS, CTRL+K for Windows
*/
@Restricted(NoExternalUse.class)
public static String translateModifierKeysForUsersPlatform(String keyboardShortcut) {
StaplerRequest2 currentRequest = Stapler.getCurrentRequest2();
currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse2());
String userAgent = currentRequest.getHeader("User-Agent");

List<String> platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD");
boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e));

return keyboardShortcut.replace("CMD", useCmdKey ? "⌘" : "CTRL");
}

@Restricted(NoExternalUse.class)
public static String formatMessage(String format, Object args) {
if (format == null) {
return args.toString();
}

return MessageFormat.format(format, args);
}
}
47 changes: 6 additions & 41 deletions core/src/main/java/hudson/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import jenkins.agents.ControllerToAgentCallable;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import jenkins.tasks.filters.EnvVarsFilterLocalRule;
Expand Down Expand Up @@ -1114,8 +1115,7 @@ public Proc launch(ProcStarter ps) throws IOException {
final String workDir = psPwd == null ? null : psPwd.getRemote();

try {
RemoteLaunchCallable remote = new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, ps.reverseStdin, out, ps.reverseStdout, err, ps.reverseStderr, ps.quiet, workDir, listener, ps.stdoutListener);
remote.setEnvVarsFilterRuleWrapper(envVarsFilterRuleWrapper);
RemoteLaunchCallable remote = new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, ps.reverseStdin, out, ps.reverseStdout, err, ps.reverseStderr, ps.quiet, workDir, listener, ps.stdoutListener, envVarsFilterRuleWrapper);
// reset the rules to prevent build step without rules configuration to re-use those
envVarsFilterRuleWrapper = null;
return new ProcImpl(getChannel().call(remote));
Expand Down Expand Up @@ -1334,46 +1334,13 @@ public interface RemoteProcess {
IOTriplet getIOtriplet();
}

private static class RemoteLaunchCallable extends MasterToSlaveCallable<RemoteProcess, IOException> {
private final @NonNull List<String> cmd;
private final @CheckForNull boolean[] masks;
private final @CheckForNull String[] env;
private final @CheckForNull InputStream in;
private final @CheckForNull OutputStream out;
private final @CheckForNull OutputStream err;
private final @CheckForNull String workDir;
private final @NonNull TaskListener listener;
private final @CheckForNull TaskListener stdoutListener;
private final boolean reverseStdin, reverseStdout, reverseStderr;
private final boolean quiet;

private EnvVarsFilterRuleWrapper envVarsFilterRuleWrapper;

RemoteLaunchCallable(@NonNull List<String> cmd, @CheckForNull boolean[] masks, @CheckForNull String[] env,
private record RemoteLaunchCallable(@NonNull List<String> cmd, @CheckForNull boolean[] masks, @CheckForNull String[] env,
@CheckForNull InputStream in, boolean reverseStdin,
@CheckForNull OutputStream out, boolean reverseStdout,
@CheckForNull OutputStream err, boolean reverseStderr,
boolean quiet, @CheckForNull String workDir, @NonNull TaskListener listener, @CheckForNull TaskListener stdoutListener) {
this.cmd = new ArrayList<>(cmd);
this.masks = masks;
this.env = env;
this.in = in;
this.out = out;
this.err = err;
this.workDir = workDir;
this.listener = listener;
this.stdoutListener = stdoutListener;
this.reverseStdin = reverseStdin;
this.reverseStdout = reverseStdout;
this.reverseStderr = reverseStderr;
this.quiet = quiet;
}

@Restricted(NoExternalUse.class)
public void setEnvVarsFilterRuleWrapper(EnvVarsFilterRuleWrapper envVarsFilterRuleWrapper) {
this.envVarsFilterRuleWrapper = envVarsFilterRuleWrapper;
}

boolean quiet, @CheckForNull String workDir,
@NonNull TaskListener listener, @CheckForNull TaskListener stdoutListener,
@CheckForNull EnvVarsFilterRuleWrapper envVarsFilterRuleWrapper) implements ControllerToAgentCallable<RemoteProcess, IOException> {
@Override
public RemoteProcess call() throws IOException {
final Channel channel = getOpenChannelOrFail();
Expand Down Expand Up @@ -1433,8 +1400,6 @@ public IOTriplet getIOtriplet() {
}
});
}

private static final long serialVersionUID = 1L;
}

private static class RemoteChannelLaunchCallable extends MasterToSlaveCallable<OutputStream, IOException> {
Expand Down
21 changes: 4 additions & 17 deletions core/src/main/java/hudson/TcpSlaveAgentListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,11 @@ public void run() {
String protocol = s.substring(9);
AgentProtocol p = AgentProtocol.of(protocol);
if (p != null) {
if (Jenkins.get().getAgentProtocols().contains(protocol)) {
LOGGER.log(p instanceof PingAgentProtocol ? Level.FINE : Level.INFO, () -> "Accepted " + protocol + " connection " + connectionInfo);
p.handle(this.s);
} else {
error("Disabled protocol:" + s, this.s);
}
} else
LOGGER.log(p instanceof PingAgentProtocol ? Level.FINE : Level.INFO, () -> "Accepted " + protocol + " connection " + connectionInfo);
p.handle(this.s);
} else {
error("Unknown protocol:", this.s);
}
} else {
error("Unrecognized protocol: " + s, this.s);
}
Expand Down Expand Up @@ -364,21 +361,11 @@ public PingAgentProtocol() {
ping = "Ping\n".getBytes(StandardCharsets.UTF_8);
}

@Override
public boolean isRequired() {
return true;
}

@Override
public String getName() {
return "Ping";
}

@Override
public String getDisplayName() {
return Messages.TcpSlaveAgentListener_PingAgentProtocol_displayName();
}

@Override
public void handle(Socket socket) throws IOException, InterruptedException {
try (socket) {
Expand Down
Loading

0 comments on commit 7d25b30

Please sign in to comment.