Skip to content

Commit

Permalink
Merge branch 'master' into use-layer-system
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jan 8, 2024
2 parents 26f2b4b + 444f2de commit 49dc591
Show file tree
Hide file tree
Showing 66 changed files with 952 additions and 497 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-release-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
is-rc: ${{ steps.set-version.outputs.is-rc }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 11
java-version: 17
cache: "maven"
- name: Set version
id: set-version
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This page provides information about contributing code to the Jenkins core codeb
1. Fork the repository on GitHub
2. Clone the forked repository to your machine
3. Install the necessary development tools. In order to develop Jenkins, you need the following:
- Java Development Kit (JDK) 11 or 17.
- Java Development Kit (JDK) 11, 17 or 21.
In the Jenkins project we usually use [Eclipse Temurin](https://adoptium.net/) or [OpenJDK](https://openjdk.java.net/), but you can use other JDKs as well.
- Apache Maven 3.8.1 or above. You can [download Maven here](https://maven.apache.org/download.cgi).
In the Jenkins project we usually use the most recent Maven release.
Expand Down
12 changes: 6 additions & 6 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -39,7 +39,7 @@ THE SOFTWARE.

<properties>
<asm.version>9.6</asm.version>
<slf4jVersion>2.0.9</slf4jVersion>
<slf4jVersion>2.0.10</slf4jVersion>
<stapler.version>1822.v120278426e1c</stapler.version>
<groovy.version>2.4.21</groovy.version>
</properties>
Expand All @@ -64,7 +64,7 @@ THE SOFTWARE.
<!-- https://docs.spring.io/spring-security/site/docs/5.5.4/reference/html5/#getting-maven-no-boot -->
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-bom</artifactId>
<version>5.8.8</version>
<version>5.8.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -82,7 +82,7 @@ THE SOFTWARE.
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
<version>33.0.0-jre</version>
</dependency>
<dependency>
<!-- Overriding Stapler’s 1.1.3 version to diagnose JENKINS-20618: -->
Expand Down Expand Up @@ -196,9 +196,9 @@ THE SOFTWARE.
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.connectbot.jbcrypt</groupId>
<groupId>org.connectbot</groupId>
<artifactId>jbcrypt</artifactId>
<version>1.0.0</version>
<version>1.0.2</version>
</dependency>
<dependency>
<!-- Groovy shell uses this, but it doesn't declare the dependency -->
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -282,7 +282,7 @@ THE SOFTWARE.
<artifactId>groovy-all</artifactId>
</dependency>
<dependency>
<groupId>org.connectbot.jbcrypt</groupId>
<groupId>org.connectbot</groupId>
<artifactId>jbcrypt</artifactId>
</dependency>
<dependency>
Expand Down
42 changes: 40 additions & 2 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import static hudson.Util.fileToPath;
import static hudson.Util.fixEmpty;
import static hudson.Util.fixEmptyAndTrim;

import com.google.common.annotations.VisibleForTesting;
import com.jcraft.jzlib.GZIPInputStream;
Expand Down Expand Up @@ -962,7 +963,7 @@ public Void invoke(File dir, VirtualChannel channel) throws IOException {
* </ul>
*
* @param archive
* The resource that represents the tgz/zip file. This URL must support the {@code Last-Modified} header.
* The resource that represents the tgz/zip file. This URL must support the {@code Last-Modified} header or the {@code ETag} header.
* (For example, you could use {@link ClassLoader#getResource}.)
* @param listener
* If non-null, a message will be printed to this listener once this method decides to
Expand All @@ -984,12 +985,18 @@ private boolean installIfNecessaryFrom(@NonNull URL archive, @NonNull TaskListen
try {
FilePath timestamp = this.child(".timestamp");
long lastModified = timestamp.lastModified();
// https://httpwg.org/specs/rfc9110.html#field.etag is the ETag specification
// Read previously stored ETag if timestamp is available
String etag = timestamp.exists() ? fixEmptyAndTrim(timestamp.readToString()) : null;
URLConnection con;
try {
con = ProxyConfiguration.open(archive);
if (lastModified != 0) {
con.setIfModifiedSince(lastModified);
}
if (etag != null) {
con.setRequestProperty("If-None-Match", etag);
}
con.connect();
} catch (IOException x) {
if (this.exists()) {
Expand All @@ -1016,7 +1023,7 @@ private boolean installIfNecessaryFrom(@NonNull URL archive, @NonNull TaskListen
return false;
}
}
if (lastModified != 0) {
if (lastModified != 0 || etag != null) {
if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED) {
return false;
} else if (responseCode != HttpURLConnection.HTTP_OK) {
Expand All @@ -1027,8 +1034,12 @@ private boolean installIfNecessaryFrom(@NonNull URL archive, @NonNull TaskListen
}

long sourceTimestamp = con.getLastModified();
String resultEtag = fixEmptyAndTrim(con.getHeaderField("ETag"));

if (this.exists()) {
if (equalETags(etag, resultEtag)) {
return false; // already up to date
}
if (lastModified != 0 && sourceTimestamp == lastModified)
return false; // already up to date
this.deleteContents();
Expand All @@ -1042,6 +1053,10 @@ private boolean installIfNecessaryFrom(@NonNull URL archive, @NonNull TaskListen
// First try to download from the agent machine.
try {
act(new Unpack(archive));
if (resultEtag != null && !equalETags(etag, resultEtag)) {
/* Store the ETag value in the timestamp file for later use */
timestamp.write(resultEtag, "UTF-8");
}
timestamp.touch(sourceTimestamp);
return true;
} catch (IOException x) {
Expand All @@ -1061,13 +1076,36 @@ private boolean installIfNecessaryFrom(@NonNull URL archive, @NonNull TaskListen
throw new IOException(String.format("Failed to unpack %s (%d bytes read of total %d)",
archive, cis.getByteCount(), con.getContentLength()), e);
}
if (resultEtag != null && !equalETags(etag, resultEtag)) {
/* Store the ETag value in the timestamp file for later use */
timestamp.write(resultEtag, "UTF-8");
}
timestamp.touch(sourceTimestamp);
return true;
} catch (IOException e) {
throw new IOException("Failed to install " + archive + " to " + remote, e);
}
}

/* Return true if etag1 equals etag2 as defined by the etag specification
https://httpwg.org/specs/rfc9110.html#field.etag
*/
private boolean equalETags(String etag1, String etag2) {
if (etag1 == null || etag2 == null) {
return false;
}
if (etag1.equals(etag2)) {
return true;
}
/* Weak tags are identified by leading characters "W/" as a marker */
/* Weak tag marker must not be considered in tag comparison.
This implements the weak comparison in the specification at
https://httpwg.org/specs/rfc9110.html#field.etag */
String opaqueTag1 = etag1.startsWith("W/") ? etag1.substring(2) : etag1;
String opaqueTag2 = etag2.startsWith("W/") ? etag2.substring(2) : etag2;
return opaqueTag1.equals(opaqueTag2);
}

// this reads from arbitrary URL
private static final class Unpack extends MasterToSlaveFileCallable<Void> {
private final URL archive;
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,13 @@ public static String getUserTimeZone() {
}

@Restricted(NoExternalUse.class)
public static String getUserTimeZonePostfix() {
public static String getUserTimeZonePostfix(Date date) {
if (!isUserTimeZoneOverride()) {
return "";
}

TimeZone tz = TimeZone.getTimeZone(getUserTimeZone());
return tz.getDisplayName(tz.observesDaylightTime(), TimeZone.SHORT);
return tz.getDisplayName(tz.inDaylightTime(date), TimeZone.SHORT, getCurrentLocale());
}

@Restricted(NoExternalUse.class)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/declarative/CLIMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import hudson.cli.CLICommand;
import hudson.util.ListBoxModel.Option;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.jvnet.hudson.annotation_indexer.Indexed;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;

/**
* Annotates methods on model objects to expose them as CLI commands.
Expand Down
27 changes: 22 additions & 5 deletions core/src/main/java/hudson/slaves/JNLPLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
* @author Stephen Connolly
* @author Kohsuke Kawaguchi
*/
@SuppressWarnings("deprecation") // see comments about CasC
public class JNLPLauncher extends ComputerLauncher {
/**
* Deprecated (only used with deprecated {@code -jnlpUrl} mode), but cannot mark it as such without breaking CasC.
*/
@DataBoundSetter
@CheckForNull
public String tunnel;

Expand All @@ -67,11 +67,9 @@ public class JNLPLauncher extends ComputerLauncher {
@Deprecated
public final transient String vmargs = null;

@Deprecated
@NonNull
private RemotingWorkDirSettings workDirSettings = RemotingWorkDirSettings.getEnabledDefaults();

@Deprecated
private boolean webSocket;

/**
Expand Down Expand Up @@ -131,7 +129,9 @@ protected Object readResolve() {
return this;
}

@Deprecated
/**
* Deprecated (only used with deprecated {@code -jnlpUrl} mode), but cannot mark it as such without breaking CasC.
*/
public RemotingWorkDirSettings getWorkDirSettings() {
return workDirSettings;
}
Expand All @@ -149,7 +149,9 @@ public boolean isLaunchSupported() {
return false;
}

@Deprecated
/**
* Deprecated (only used with deprecated {@code -jnlpUrl} mode), but cannot mark it as such without breaking CasC.
*/
public boolean isWebSocket() {
return webSocket;
}
Expand All @@ -162,6 +164,21 @@ public void setWebSocket(boolean webSocket) {
this.webSocket = webSocket;
}

/**
* Deprecated (only used with deprecated {@code -jnlpUrl} mode), but cannot mark it as such without breaking CasC.
*/
public String getTunnel() {
return tunnel;
}

/**
* Deprecated (only used with deprecated {@code -jnlpUrl} mode), but cannot mark it as such without breaking CasC.
*/
@DataBoundSetter
public void setTunnel(String tunnel) {
this.tunnel = tunnel;
}

@Override
public void launch(SlaveComputer computer, TaskListener listener) {
// do nothing as we cannot self start
Expand Down
Loading

0 comments on commit 49dc591

Please sign in to comment.