Skip to content

Commit

Permalink
Merge branch 'master' into keyboard-shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Apr 28, 2022
2 parents 7bce4da + c350527 commit 7ed6ff0
Show file tree
Hide file tree
Showing 117 changed files with 1,147 additions and 739 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ work
*.iml
*.iws
*.ipr
.idea
/.idea/*
!/.idea/icon.svg
!/.idea/.name
out

# Eclipse and VSCode project files
Expand Down
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions .idea/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 6 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
* It makes assumptions about plugins being installed, labels mapping to nodes that can build what is needed, etc.
*/

def buildNumber = BUILD_NUMBER as int; if (buildNumber > 1) milestone(buildNumber - 1); milestone(buildNumber) // JENKINS-43353 / JENKINS-58625

def failFast = false
// Same memory sizing for both builds and ATH
def javaOpts = [
'JAVA_OPTS=-Xmx1536m -Xms512m',
'MAVEN_OPTS=-Xmx1536m -Xms512m',
]

properties([
buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '3')),
Expand Down Expand Up @@ -43,7 +36,7 @@ for (i = 0; i < buildTypes.size(); i++) {
// First stage is actually checking out the source. Since we're using Multibranch
// currently, we can use "checkout scm".
stage('Checkout') {
checkout scm
infra.checkoutSCM()
}

def changelistF = "${pwd tmp: true}/changelist"
Expand All @@ -55,6 +48,7 @@ for (i = 0; i < buildTypes.size(); i++) {
realtimeJUnit(healthScaleFactor: 20.0, testResults: '*/target/surefire-reports/*.xml,war/junit.xml') {
def mavenOptions = [
'-Pdebug',
'-Penable-jacoco',
'--update-snapshots',
"-Dmaven.repo.local=$m2repo",
'-Dmaven.test.failure.ignore',
Expand All @@ -67,7 +61,7 @@ for (i = 0; i < buildTypes.size(); i++) {
'clean',
'install',
]
infra.runMaven(mavenOptions, jdk.toString(), javaOpts, null, true)
infra.runMaven(mavenOptions, jdk)
if (isUnix()) {
sh 'git add . && git diff --exit-code HEAD'
}
Expand All @@ -89,6 +83,7 @@ for (i = 0; i < buildTypes.size(); i++) {
error 'There were test failures; halting early'
}
if (buildType == 'Linux' && jdk == jdks[0]) {
publishCoverage calculateDiffForChangeRequests: true, adapters: [jacocoAdapter('coverage/target/site/jacoco-aggregate/jacoco.xml')]
def folders = env.JOB_NAME.split('/')
if (folders.length > 1) {
discoverGitReferenceBuild(scm: folders[1])
Expand Down Expand Up @@ -125,7 +120,7 @@ for (i = 0; i < buildTypes.size(); i++) {
dir(m2repo) {
archiveArtifacts(
artifacts: "**/*$changelist/*$changelist*",
excludes: '**/*.lastUpdated,**/jenkins-test*/',
excludes: '**/*.lastUpdated,**/jenkins-coverage*/,**/jenkins-test*/',
allowEmptyArchive: true, // in case we forgot to reincrementalify
fingerprint: true
)
Expand Down Expand Up @@ -153,7 +148,7 @@ builds.ath = {
'war',
'package',
]
infra.runMaven(mavenOptions, '11', javaOpts, null, true)
infra.runMaven(mavenOptions, 11)
dir('war/target') {
fileUri = 'file://' + pwd() + '/jenkins.war'
}
Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.2</version>
<version>5.6.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
39 changes: 39 additions & 0 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

<properties>
<mina-sshd.version>2.8.0</mina-sshd.version>
<!-- Filled in by jacoco-maven-plugin -->
<jacocoSurefireArgs />
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -123,6 +125,9 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<!-- Version specified in grandparent POM -->
<configuration>
<argLine>@{jacocoSurefireArgs}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -209,4 +214,38 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>enable-jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<!-- Version specified in parent POM -->
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacocoSurefireArgs</propertyName>
<includes>
<include>hudson/*</include>
<include>hudson/**/*</include>
<include>jenkins/*</include>
<include>jenkins/**/*</include>
<include>org/jenkins/**/*</include>
</includes>
<excludes>
<exclude>**/Messages.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
37 changes: 36 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ THE SOFTWARE.
<staplerFork>true</staplerFork>
<hamcrest.version>2.2</hamcrest.version>
<xmlunit.version>2.9.0</xmlunit.version>
<!-- Filled in by jacoco-maven-plugin -->
<jacocoSurefireArgs />
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -717,6 +719,7 @@ THE SOFTWARE.
<artifactId>maven-surefire-plugin</artifactId>
<!-- Version specified in grandparent POM -->
<configuration>
<argLine>@{jacocoSurefireArgs}</argLine>
<forkCount>0.5C</forkCount>
<reuseForks>false</reuseForks>
</configuration>
Expand Down Expand Up @@ -829,11 +832,43 @@ THE SOFTWARE.
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Make sure to keep the directives in test/pom.xml and war/pom.xml in sync with these. -->
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
<argLine>@{jacocoSurefireArgs} --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>enable-jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<!-- Version specified in parent POM -->
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacocoSurefireArgs</propertyName>
<includes>
<include>hudson/*</include>
<include>hudson/**/*</include>
<include>jenkins/*</include>
<include>jenkins/**/*</include>
<include>org/jenkins/**/*</include>
</includes>
<excludes>
<exclude>**/Messages.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
27 changes: 27 additions & 0 deletions core/src/main/java/hudson/logging/LogRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.thoughtworks.xstream.XStream;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.BulkChange;
import hudson.Extension;
Expand All @@ -43,6 +44,7 @@
import hudson.remoting.VirtualChannel;
import hudson.slaves.ComputerListener;
import hudson.util.CopyOnWriteList;
import hudson.util.FormValidation;
import hudson.util.HttpResponses;
import hudson.util.RingBufferLogHandler;
import hudson.util.XStream2;
Expand Down Expand Up @@ -187,6 +189,31 @@ public static Set<String> getAutoCompletionCandidates(List<String> loggerNamesLi
return relevantPrefixes;
}

/**
* Validate the name.
*
* @return {@link FormValidation#ok} if the log target is not empty, otherwise {@link
* FormValidation#warning} with a message explaining the problem.
*/
@NonNull
@Restricted(NoExternalUse.class)
@VisibleForTesting
public FormValidation doCheckName(@QueryParameter String value, @QueryParameter String level) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
try {
if ((Util.fixEmpty(level) == null || Level.parse(level).intValue() <= Level.FINE.intValue())
&& Util.fixEmpty(value) == null) {
return FormValidation.warning(Messages.LogRecorder_Target_Empty_Warning());
}
} catch (IllegalArgumentException iae) {
// We cannot figure out the level, if the name is empty show a warning
if (Util.fixEmpty(value) == null) {
return FormValidation.warning(Messages.LogRecorder_Target_Empty_Warning());
}
}
return FormValidation.ok();
}

@Restricted(NoExternalUse.class)
public AutoCompletionCandidates doAutoCompleteLoggerName(@QueryParameter String value) {
if (value == null) {
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/java/hudson/logging/LogRecorderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import hudson.FeedAdapter;
import hudson.Functions;
import hudson.RestrictedSince;
import hudson.Util;
import hudson.init.Initializer;
import hudson.model.AbstractModelObject;
import hudson.model.Failure;
import hudson.model.RSS;
import hudson.util.CopyOnWriteMap;
import hudson.util.FormValidation;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
Expand Down Expand Up @@ -161,6 +163,20 @@ public HttpResponse doNewLogRecorder(@QueryParameter String name) {
return new HttpRedirect(name + "/configure");
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckNewName(@QueryParameter String name) {
if (Util.fixEmpty(name) == null) {
return FormValidation.ok();
}

try {
Jenkins.checkGoodName(name);
} catch (Failure e) {
return FormValidation.error(e.getMessage());
}
return FormValidation.ok();
}

@Override
public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
ContextMenu menu = new ContextMenu();
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/hudson/model/MyViewsProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ public String getUrl() {

@Override
public void save() throws IOException {
user.save();
if (user != null) {
user.save();
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/UpdateCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ private void addStatus(Throwable e) {

public String[] getStatuses() {
synchronized (statuses) {
return statuses.toArray(new String[statuses.size()]);
return statuses.toArray(new String[0]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/UpdateSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ public Plugin(String sourceId, JSONObject o) {
}
}
final String popularityFromJson = get(o, "popularity");
Double popularity = 0.0;
double popularity = 0.0;
if (popularityFromJson != null) {
try {
popularity = Double.parseDouble(popularityFromJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import jenkins.MasterToSlaveFileCallable;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand All @@ -54,7 +56,8 @@ public TemporarySpaceMonitor(String freeSpaceThreshold) throws ParseException {
public TemporarySpaceMonitor() {}

public DiskSpace getFreeSpace(Computer c) {
return DESCRIPTOR.get(c);
DiskSpaceMonitorDescriptor descriptor = (DiskSpaceMonitorDescriptor) Jenkins.get().getDescriptor(TemporarySpaceMonitor.class);
return descriptor != null ? descriptor.get(c) : null;
}

@Override
Expand All @@ -68,6 +71,7 @@ public String getColumnCaption() {
* Use injection
*/
@Deprecated
@Restricted(NoExternalUse.class)
@SuppressFBWarnings(value = "MS_PKGPROTECT", justification = "for backward compatibility")
public static /*almost final*/ DiskSpaceMonitorDescriptor DESCRIPTOR;

Expand Down Expand Up @@ -100,7 +104,7 @@ protected Callable<DiskSpace, IOException> createCallable(Computer c) {
*/
@Deprecated
public static DiskSpaceMonitorDescriptor install() {
return DESCRIPTOR;
return (DiskSpaceMonitorDescriptor) Jenkins.get().getDescriptor(TemporarySpaceMonitor.class);
}

protected static final class GetTempSpace extends MasterToSlaveFileCallable<DiskSpace> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
t = t.getCause();
}
}
if (t != null && t instanceof JellyTagException) {
if (t instanceof JellyTagException) {
JellyTagException jte = (JellyTagException) t;
Throwable cause = jte.getCause();
if (cause instanceof AccessDeniedException || cause instanceof AuthenticationException) {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/hudson/slaves/JNLPLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void launch(SlaveComputer computer, TaskListener listener) {
* Use {@link Jenkins#getDescriptor(Class)}
*/
@Deprecated
@Restricted(NoExternalUse.class)
public static /*almost final*/ Descriptor<ComputerLauncher> DESCRIPTOR;

/**
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/tasks/ArtifactArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import net.sf.json.JSONObject;
import org.apache.tools.ant.types.FileSet;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
Expand Down Expand Up @@ -335,6 +337,7 @@ public BuildStepMonitor getRequiredMonitorService() {
* Use {@link jenkins.model.Jenkins#getDescriptorByType(Class)} instead.
*/
@Deprecated
@Restricted(NoExternalUse.class)
public static volatile DescriptorImpl DESCRIPTOR;

@Extension @Symbol("archiveArtifacts")
Expand Down
Loading

0 comments on commit 7ed6ff0

Please sign in to comment.