Skip to content

Commit

Permalink
Merge branch 'master' into progress-bar-new
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Dec 10, 2023
2 parents 7a0e57e + cabc8f6 commit 222e649
Show file tree
Hide file tree
Showing 122 changed files with 1,121 additions and 534 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
root = true

[*.{js, scss, css, hbs}]
[*.{js, scss, css, hbs, svg}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ jobs:
runs-on: ubuntu-latest
if: github.repository_owner == 'jenkinsci'
steps:
- uses: tibdex/github-app-token@v1
- uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.JENKINS_CHANGELOG_UPDATER_APP_ID }}
installation_retrieval_mode: repository
installation_retrieval_payload: jenkins-infra/jenkins.io
private_key: ${{ secrets.JENKINS_CHANGELOG_UPDATER_PRIVATE_KEY }}
repository: jenkins-infra/jenkins.io
repositories: >-
["jenkins.io"]
- name: Check out
uses: actions/checkout@v4
with:
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/publish-release-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
outputs:
project-version: ${{ steps.set-version.outputs.project-version }}
is-lts: ${{ steps.set-version.outputs.is-lts }}
is-rc: ${{ steps.set-version.outputs.is-rc }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 11
Expand All @@ -34,16 +35,23 @@ jobs:
is_lts=false
fi
echo "Version is $version, is_lts: $is_lts"
is_rc=false
if [[ ${version} == *"-SNAPSHOT" ]]; then
is_rc=true
fi
echo "Version is $version, is_lts: $is_lts, is_rc: $is_rc"
echo "is-lts=${is_lts}" >> $GITHUB_OUTPUT
echo "project-version=$version" >> $GITHUB_OUTPUT
echo "is-rc=${is_rc}" >> $GITHUB_OUTPUT
war:
permissions:
contents: write # to upload release asset (softprops/action-gh-release)

runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch war
id: fetch-war
Expand Down Expand Up @@ -76,6 +84,7 @@ jobs:

runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch Deb
id: fetch-deb
Expand Down Expand Up @@ -110,6 +119,7 @@ jobs:

runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch RPM
id: fetch-rpm
Expand Down Expand Up @@ -145,6 +155,7 @@ jobs:

runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch MSI
id: fetch-msi
Expand Down Expand Up @@ -180,6 +191,7 @@ jobs:

runs-on: ubuntu-latest
needs: determine-version
if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
steps:
- name: Fetch suse rpm
id: fetch-suse-rpm
Expand Down
2 changes: 1 addition & 1 deletion .gitpod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM gitpod/workspace-full

ARG MAVEN_VERSION=3.9.5
ARG MAVEN_VERSION=3.9.6

RUN brew install gh && \
bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk default maven ${MAVEN_VERSION}"
4 changes: 2 additions & 2 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ THE SOFTWARE.
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.0</version>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
Expand Down Expand Up @@ -366,7 +366,7 @@ THE SOFTWARE.
<!-- provided by jcl-over-slf4j -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<version>1.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions cli/src/test/java/hudson/cli/PrivateKeyProviderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void assertKeyPairNotNull(File file, String password) throws IOException
}

/**
key command: ssh-keygen -f dsa-password -t dsa -b 1024 -m PEM -p password
key command: ssh-keygen -f dsa-password -t dsa -b 1024 -m PEM -P password
*/
@Test
public void loadKeyDSAPassword() throws IOException, GeneralSecurityException {
Expand All @@ -61,7 +61,7 @@ public void loadKeyRSA() throws IOException, GeneralSecurityException {
}

/**
key command: ssh-keygen -f rsa-password -t rsa -b 1024 -m PEM -p password
key command: ssh-keygen -f rsa-password -t rsa -b 1024 -m PEM -P password
*/
@Test
public void loadKeyRSAPassword() throws IOException, GeneralSecurityException {
Expand All @@ -80,7 +80,7 @@ public void loadKeyOpenSSH() throws IOException, GeneralSecurityException {
}

/**
key command: ssh-keygen -f openssh-unsupported -t rsa -b 1024 -m PKCS8 -p password
key command: ssh-keygen -f openssh-unsupported -t rsa -b 1024 -m PKCS8 -P password
*/
@Test
public void loadKeyOpenSSHPKCS8() throws IOException, GeneralSecurityException {
Expand Down
25 changes: 25 additions & 0 deletions core/src/main/java/hudson/ExtensionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,31 @@ public static <T> ExtensionList<T> create(Jenkins jenkins, Class<T> type) {
return all.get(0);
}

/**
* Convenience method allowing lookup of the instance of a given type with the highest ordinal.
* Equivalent to {@code ExtensionList.lookup(type).get(0)} if there is at least one instance,
* and throws an {@link IllegalStateException} otherwise if no instance could be found.
*
* @param type The type to look up.
* @return the singleton instance of the given type in its list.
* @throws IllegalStateException if there are no instances
*
* @since TODO
*/
public static @NonNull <U> U lookupFirst(Class<U> type) {
var all = lookup(type);
if (!all.isEmpty()) {
return all.get(0);
} else {
if (Main.isUnitTest) {
throw new IllegalStateException("Found no instances of " + type.getName() +
" registered (possible annotation processor issue); try using `mvn clean test -Dtest=…` rather than an IDE test runner");
} else {
throw new IllegalStateException("Found no instances of " + type.getName() + " registered");
}
}
}

/**
* Places to store static-scope legacy instances.
*/
Expand Down
10 changes: 7 additions & 3 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2318,13 +2318,17 @@ public static String humanReadableByteSize(long size) {
double number = size;
if (number >= 1024) {
number = number / 1024;
measure = "KB";
measure = "KiB";
if (number >= 1024) {
number = number / 1024;
measure = "MB";
measure = "MiB";
if (number >= 1024) {
number = number / 1024;
measure = "GB";
measure = "GiB";
if (number >= 1024) {
number = number / 1024;
measure = "TiB";
}
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1803,13 +1803,7 @@ public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, Ser
jenkins.checkPermission(Jenkins.ADMINISTER);

ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm());
if (pc.name == null) {
jenkins.proxy = null;
ProxyConfiguration.getXmlFile().delete();
} else {
jenkins.proxy = pc;
jenkins.proxy.save();
}
ProxyConfigurationManager.saveProxyConfiguration(pc);
return new HttpRedirect("advanced");
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/ProxyConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ public FormValidation doValidateProxy(
}
try {
HttpResponse<Void> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.discarding());
if (httpResponse.statusCode() == HttpURLConnection.HTTP_OK) {
return FormValidation.ok(Messages.ProxyConfiguration_Success());
if (httpResponse.statusCode() < HttpURLConnection.HTTP_BAD_REQUEST) {
return FormValidation.ok(Messages.ProxyConfiguration_Success(httpResponse.statusCode()));
}
return FormValidation.error(Messages.ProxyConfiguration_FailedToConnect(testUrl, httpResponse.statusCode()));
} catch (IOException e) {
Expand Down
72 changes: 72 additions & 0 deletions core/src/main/java/hudson/ProxyConfigurationManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* The MIT License
*
* Copyright (c) 2023, CloudBees Inc, and other contributors
*
* 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 hudson;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.Descriptor;
import java.io.IOException;
import jenkins.model.GlobalConfiguration;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;

@Extension @Restricted(NoExternalUse.class)
public class ProxyConfigurationManager extends GlobalConfiguration {

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

public Descriptor<ProxyConfiguration> getProxyDescriptor() {
return Jenkins.get().getDescriptor(ProxyConfiguration.class);
}

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, json);
try {
saveProxyConfiguration(pc);
} catch (IOException e) {
throw new FormException(e.getMessage(), e, null);
}
return true;
}

public static void saveProxyConfiguration(ProxyConfiguration pc) throws IOException {
Jenkins jenkins = Jenkins.get();
if (pc.name == null) {
jenkins.proxy = null;
ProxyConfiguration.getXmlFile().delete();
} else {
jenkins.proxy = pc;
jenkins.proxy.save();
}
}

}
10 changes: 10 additions & 0 deletions core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import hudson.model.Queue.FlyweightTask;
import hudson.model.labels.LabelAtom;
import hudson.model.queue.WorkUnit;
import hudson.node_monitors.AbstractDiskSpaceMonitor;
import hudson.node_monitors.DiskSpaceMonitorNodeProperty;
import hudson.node_monitors.NodeMonitor;
import hudson.remoting.Channel;
import hudson.remoting.VirtualChannel;
Expand Down Expand Up @@ -1515,6 +1517,14 @@ public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOExc
Node result = node.reconfigure(req, req.getSubmittedForm());
Jenkins.get().getNodesObject().replaceNode(this.getNode(), result);

if (result.getNodeProperty(DiskSpaceMonitorNodeProperty.class) != null) {
for (NodeMonitor monitor : NodeMonitor.getAll()) {
if (monitor instanceof AbstractDiskSpaceMonitor) {
monitor.data(this);
}
}
}

// take the user back to the agent top page.
rsp.sendRedirect2("../" + result.getNodeName() + '/');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void error(Computer c, Throwable x) {
/**
* Result object for {@link AbstractAsyncNodeMonitorDescriptor#monitorDetailed()} to facilitate extending information
* returned in the future.
*
* <p>
* The {@link #getMonitoringData()} provides the results of the monitoring as {@link #monitor()} does. Note the value
* in the map can be {@code null} for several reasons:
* <ul>
Expand All @@ -149,8 +149,8 @@ private void error(Computer c, Throwable x) {
* <li>The {@link AbstractAsyncNodeMonitorDescriptor#createCallable} has returned null.</li>
* </ul>
*
* Clients can distinguishing among these states based on the additional data attached to this object. {@link #getSkipped()}
* returns computers that was not monitored as they ware either offline or monitor produced {@code null} {@link Callable}.
* Clients can distinguish among these states based on the additional data attached to this object. {@link #getSkipped()}
* returns computers that were not monitored as they were either offline or monitor produced {@code null} {@link Callable}.
*/
protected static final class Result<T> {
private static final long serialVersionUID = -7671448355804481216L;
Expand All @@ -163,15 +163,15 @@ private Result(@NonNull Map<Computer, T> data, @NonNull Collection<Computer> ski
this.skipped = new ArrayList<>(skipped);
}

protected @NonNull Map<Computer, T> getMonitoringData() {
public @NonNull Map<Computer, T> getMonitoringData() {
return data;
}

/**
* Computers that ware skipped during monitoring as they either do not have a a channel (offline) or the monitor
* have not produced the Callable. Computers that caused monitor to throw exception are not returned here.
* Computers that were skipped during monitoring as they either do not have a channel (offline) or the monitor
* has not produced the Callable. Computers that caused monitor to throw exception are not returned here.
*/
protected @NonNull List<Computer> getSkipped() {
public @NonNull List<Computer> getSkipped() {
return skipped;
}
}
Expand Down
Loading

0 comments on commit 222e649

Please sign in to comment.