mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 04:52:20 +00:00
Merge commit '659b6af1904ff4aa89b1e987bf60bc609082b900' of git://github.com/jenkinsci/jenkins
This commit is contained in:
commit
5add213d14
131 files changed
+630
-418
No files matched your search
@@ -42,7 +42,6 @@ import com.google.inject.spi.ProvisionListener;
|
||||
import hudson.init.InitMilestone;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.util.ReflectionUtils;
|
||||
import jenkins.ExtensionComponentSet;
|
||||
import jenkins.ExtensionFilter;
|
||||
import jenkins.ExtensionRefreshException;
|
||||
|
||||
@@ -245,8 +245,7 @@ public class ExtensionList<T> extends AbstractList<T> implements OnMaster {
|
||||
}
|
||||
|
||||
private <T> boolean removeComponent(Collection<ExtensionComponent<T>> collection, Object t) {
|
||||
for (Iterator<ExtensionComponent<T>> itr = collection.iterator(); itr.hasNext();) {
|
||||
ExtensionComponent<T> c = itr.next();
|
||||
for (ExtensionComponent<T> c : collection) {
|
||||
if (c.getInstance().equals(t)) {
|
||||
return collection.remove(c);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import static java.lang.annotation.ElementType.TYPE;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Target;
|
||||
import jenkins.util.io.OnMaster;
|
||||
|
||||
/**
|
||||
* Marker interface that designates extensible components
|
||||
|
||||
@@ -132,6 +132,7 @@ import org.jenkinsci.remoting.RoleChecker;
|
||||
import org.jenkinsci.remoting.RoleSensitive;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.Function;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
|
||||
import static hudson.FilePath.TarCompression.GZIP;
|
||||
@@ -3262,9 +3263,14 @@ public final class FilePath implements Serializable {
|
||||
Path parentAbsolutePath = Util.fileToPath(parentFile.getAbsoluteFile());
|
||||
Path parentRealPath;
|
||||
try {
|
||||
parentRealPath = parentAbsolutePath.toRealPath();
|
||||
if (Functions.isWindows()) {
|
||||
parentRealPath = this.windowsToRealPath(parentAbsolutePath);
|
||||
} else {
|
||||
parentRealPath = parentAbsolutePath.toRealPath();
|
||||
}
|
||||
}
|
||||
catch(NoSuchFileException e) {
|
||||
catch (NoSuchFileException e) {
|
||||
LOGGER.log(Level.FINE, String.format("Cannot find the real path to the parentFile: %s", parentAbsolutePath), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3296,10 +3302,11 @@ public final class FilePath implements Serializable {
|
||||
try{
|
||||
Path child = currentFileAbsolutePath.toRealPath();
|
||||
if (!child.startsWith(parentRealPath)) {
|
||||
LOGGER.log(Level.FINE, "Child [{0}] does not start with parent [{1}] => not descendant", new Object[]{ child, parentRealPath });
|
||||
return false;
|
||||
}
|
||||
} catch (NoSuchFileException e) {
|
||||
// nonexistent file
|
||||
// nonexistent file / Windows Server 2016 + MSFT docker
|
||||
// in case this folder / file will be copied somewhere else,
|
||||
// it becomes the responsibility of that system to check the isDescendant with the existing links
|
||||
// we are not taking the parentRealPath to avoid possible problem
|
||||
@@ -3322,6 +3329,21 @@ public final class FilePath implements Serializable {
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
private @Nonnull Path windowsToRealPath(@Nonnull Path path) throws IOException {
|
||||
try {
|
||||
return path.toRealPath();
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.log(Level.FINE, String.format("relaxedToRealPath cannot use the regular toRealPath on %s, trying with toRealPath(LinkOption.NOFOLLOW_LINKS)", path), e);
|
||||
}
|
||||
}
|
||||
|
||||
// that's required for specific environment like Windows Server 2016, running MSFT docker
|
||||
// where the root is a <SYMLINKD>
|
||||
return path.toRealPath(LinkOption.NOFOLLOW_LINKS);
|
||||
}
|
||||
}
|
||||
|
||||
private static final SoloFilePathFilter UNRESTRICTED = SoloFilePathFilter.wrap(FilePathFilter.UNRESTRICTED);
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.jenkinsci.Symbol;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
||||
@@ -2006,7 +2006,7 @@ public class Functions {
|
||||
if(size < 1024){
|
||||
return size + " " + measure;
|
||||
}
|
||||
Double number = new Double(size);
|
||||
double number = size;
|
||||
if(number>=1024){
|
||||
number = number/1024;
|
||||
measure = "KB";
|
||||
|
||||
@@ -591,10 +591,10 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
});
|
||||
|
||||
// All plugins are loaded. Now we can figure out who depends on who.
|
||||
requires(PLUGINS_PREPARED).attains(COMPLETED).add("Resolving Dependant Plugins Graph", new Executable() {
|
||||
requires(PLUGINS_PREPARED).attains(COMPLETED).add("Resolving Dependent Plugins Graph", new Executable() {
|
||||
@Override
|
||||
public void run(Reactor reactor) throws Exception {
|
||||
resolveDependantPlugins();
|
||||
resolveDependentPlugins();
|
||||
}
|
||||
});
|
||||
}});
|
||||
@@ -948,7 +948,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
|
||||
// Redo who depends on who.
|
||||
resolveDependantPlugins();
|
||||
resolveDependentPlugins();
|
||||
|
||||
try {
|
||||
Jenkins.get().refreshExtensions();
|
||||
@@ -960,40 +960,40 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public synchronized void resolveDependantPlugins() {
|
||||
public synchronized void resolveDependentPlugins() {
|
||||
for (PluginWrapper plugin : plugins) {
|
||||
// Set of optional dependants plugins of plugin
|
||||
Set<String> optionalDependants = new HashSet<>();
|
||||
Set<String> dependants = new HashSet<>();
|
||||
for (PluginWrapper possibleDependant : plugins) {
|
||||
// No need to check if plugin is dependant of itself
|
||||
if(possibleDependant.getShortName().equals(plugin.getShortName())) {
|
||||
// Set of optional dependents plugins of plugin
|
||||
Set<String> optionalDependents = new HashSet<>();
|
||||
Set<String> dependents = new HashSet<>();
|
||||
for (PluginWrapper possibleDependent : plugins) {
|
||||
// No need to check if plugin is dependent of itself
|
||||
if(possibleDependent.getShortName().equals(plugin.getShortName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The plugin could have just been deleted. If so, it doesn't
|
||||
// count as a dependant.
|
||||
if (possibleDependant.isDeleted()) {
|
||||
// count as a dependent.
|
||||
if (possibleDependent.isDeleted()) {
|
||||
continue;
|
||||
}
|
||||
List<Dependency> dependencies = possibleDependant.getDependencies();
|
||||
List<Dependency> dependencies = possibleDependent.getDependencies();
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (dependency.shortName.equals(plugin.getShortName())) {
|
||||
dependants.add(possibleDependant.getShortName());
|
||||
dependents.add(possibleDependent.getShortName());
|
||||
|
||||
// If, in addition, the dependency is optional, add to the optionalDependants list
|
||||
// If, in addition, the dependency is optional, add to the optionalDependents list
|
||||
if (dependency.optional) {
|
||||
optionalDependants.add(possibleDependant.getShortName());
|
||||
optionalDependents.add(possibleDependent.getShortName());
|
||||
}
|
||||
|
||||
// already know possibleDependant depends on plugin, no need to continue with the rest of
|
||||
// dependencies. We continue with the next possibleDependant
|
||||
// already know possibleDependent depends on plugin, no need to continue with the rest of
|
||||
// dependencies. We continue with the next possibleDependent
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.setDependants(dependants);
|
||||
plugin.setOptionalDependants(optionalDependants);
|
||||
plugin.setDependents(dependents);
|
||||
plugin.setOptionalDependents(optionalDependents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1545,7 +1545,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
|
||||
// Fire a one-off thread to wait for the plugins to be deployed and then
|
||||
// refresh the dependant plugins list.
|
||||
// refresh the dependent plugins list.
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1563,7 +1563,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
}
|
||||
// All the plugins are installed. It's now safe to refresh.
|
||||
resolveDependantPlugins();
|
||||
resolveDependentPlugins();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1941,10 +1941,10 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a list of plugins using a strategy for their dependants plugins.
|
||||
* @param strategy the strategy regarding how the dependant plugins are processed
|
||||
* Disable a list of plugins using a strategy for their dependents plugins.
|
||||
* @param strategy the strategy regarding how the dependent plugins are processed
|
||||
* @param plugins the list of plugins
|
||||
* @return the list of results for every plugin and their dependant plugins.
|
||||
* @return the list of results for every plugin and their dependent plugins.
|
||||
* @throws IOException see {@link PluginWrapper#disable()}
|
||||
*/
|
||||
public @NonNull List<PluginWrapper.PluginDisableResult> disablePlugins(@NonNull PluginWrapper.PluginDisableStrategy strategy, @NonNull List<String> plugins) throws IOException {
|
||||
|
||||
@@ -208,12 +208,12 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
/**
|
||||
* List of plugins that depend on this plugin.
|
||||
*/
|
||||
private Set<String> dependants = Collections.emptySet();
|
||||
private Set<String> dependents = Collections.emptySet();
|
||||
|
||||
/**
|
||||
* List of plugins that depend optionally on this plugin.
|
||||
*/
|
||||
private Set<String> optionalDependants = Collections.emptySet();
|
||||
private Set<String> optionalDependents = Collections.emptySet();
|
||||
|
||||
/**
|
||||
* The core can depend on a plugin if it is bundled. Sometimes it's the only thing that
|
||||
@@ -223,37 +223,69 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Set the list of components that depend on this plugin.
|
||||
* @param dependants The list of components that depend on this plugin.
|
||||
* @param dependents The list of components that depend on this plugin.
|
||||
*/
|
||||
public void setDependants(@Nonnull Set<String> dependants) {
|
||||
this.dependants = dependants;
|
||||
public void setDependents(@Nonnull Set<String> dependents) {
|
||||
this.dependents = dependents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link setDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDependants(@Nonnull Set<String> dependents) {
|
||||
setDependents(dependents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of components that depend optionally on this plugin.
|
||||
* @param optionalDependants The list of components that depend optionally on this plugin.
|
||||
* @param optionalDependents The list of components that depend optionally on this plugin.
|
||||
*/
|
||||
public void setOptionalDependants(@Nonnull Set<String> optionalDependants) {
|
||||
this.optionalDependants = optionalDependants;
|
||||
public void setOptionalDependents(@Nonnull Set<String> optionalDependents) {
|
||||
this.optionalDependents = optionalDependents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link setOptionalDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOptionalDependants(@Nonnull Set<String> optionalDependents) {
|
||||
setOptionalDependents(dependents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of components that depend on this plugin.
|
||||
* @return The list of components that depend on this plugin.
|
||||
*/
|
||||
public @Nonnull Set<String> getDependants() {
|
||||
if (isBundled && dependants.isEmpty()) {
|
||||
public @Nonnull Set<String> getDependents() {
|
||||
if (isBundled && dependents.isEmpty()) {
|
||||
return CORE_ONLY_DEPENDANT;
|
||||
} else {
|
||||
return dependants;
|
||||
return dependents;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link getDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public @Nonnull Set<String> getDependants() {
|
||||
return getDependents();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The list of components that depend optionally on this plugin.
|
||||
*/
|
||||
public @Nonnull Set<String> getOptionalDependents() {
|
||||
return optionalDependents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link getOptionalDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public @Nonnull Set<String> getOptionalDependants() {
|
||||
return optionalDependants;
|
||||
return getOptionalDependents();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,8 +293,16 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
* @return {@code true} if something (Jenkins core, or another plugin) depends on this
|
||||
* plugin, otherwise {@code false}.
|
||||
*/
|
||||
public boolean hasDependents() {
|
||||
return (isBundled || !dependents.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link hasDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasDependants() {
|
||||
return (isBundled || !dependants.isEmpty());
|
||||
return hasDependents();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,10 +310,17 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
* @return {@code true} if something (Jenkins core, or another plugin) depends optionally on this
|
||||
* plugin, otherwise {@code false}.
|
||||
*/
|
||||
public boolean hasOptionalDependants() {
|
||||
return !optionalDependants.isEmpty();
|
||||
public boolean hasOptionalDependents() {
|
||||
return !optionalDependents.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link hasOptionalDependents}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasOptionalDependants() {
|
||||
return hasOptionalDependents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this plugin depend on any other plugins.
|
||||
@@ -597,7 +644,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
/**
|
||||
* Disable this plugin using a strategy.
|
||||
* @param strategy strategy to use
|
||||
* @return an object representing the result of the disablement of this plugin and its dependants plugins.
|
||||
* @return an object representing the result of the disablement of this plugin and its dependents plugins.
|
||||
*/
|
||||
public @Nonnull PluginDisableResult disable(@Nonnull PluginDisableStrategy strategy) {
|
||||
PluginDisableResult result = new PluginDisableResult(shortName);
|
||||
@@ -608,55 +655,55 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Act as a flag indicating if this plugin, finally, can be disabled. If there is a not-disabled-dependant
|
||||
// Act as a flag indicating if this plugin, finally, can be disabled. If there is a not-disabled-dependent
|
||||
// plugin, this one couldn't be disabled.
|
||||
String aDependantNotDisabled = null;
|
||||
String aDependentNotDisabled = null;
|
||||
|
||||
// List of dependants plugins to 'check'. 'Check' means disable for mandatory or all strategies, or review if
|
||||
// this dependant-mandatory plugin is enabled in order to return an error for the NONE strategy.
|
||||
Set<String> dependantsToCheck = dependantsToCheck(strategy);
|
||||
// List of dependents plugins to 'check'. 'Check' means disable for mandatory or all strategies, or review if
|
||||
// this dependent-mandatory plugin is enabled in order to return an error for the NONE strategy.
|
||||
Set<String> dependentsToCheck = dependentsToCheck(strategy);
|
||||
|
||||
// Review all the dependants and add to the plugin result what happened with its dependants
|
||||
for (String dependant : dependantsToCheck) {
|
||||
PluginWrapper dependantPlugin = parent.getPlugin(dependant);
|
||||
// Review all the dependents and add to the plugin result what happened with its dependents
|
||||
for (String dependent : dependentsToCheck) {
|
||||
PluginWrapper dependentPlugin = parent.getPlugin(dependent);
|
||||
|
||||
// The dependant plugin doesn't exist, add an error to the report
|
||||
if (dependantPlugin == null) {
|
||||
PluginDisableResult dependantStatus = new PluginDisableResult(dependant, NO_SUCH_PLUGIN, Messages.PluginWrapper_NoSuchPlugin(dependant));
|
||||
result.addDependantDisableStatus(dependantStatus);
|
||||
// The dependent plugin doesn't exist, add an error to the report
|
||||
if (dependentPlugin == null) {
|
||||
PluginDisableResult dependentStatus = new PluginDisableResult(dependent, NO_SUCH_PLUGIN, Messages.PluginWrapper_NoSuchPlugin(dependent));
|
||||
result.addDependentDisableStatus(dependentStatus);
|
||||
|
||||
// If the strategy is none and there is some enabled dependant plugin, the plugin cannot be disabled. If
|
||||
// this dependant plugin is not enabled, continue searching for one enabled.
|
||||
// If the strategy is none and there is some enabled dependent plugin, the plugin cannot be disabled. If
|
||||
// this dependent plugin is not enabled, continue searching for one enabled.
|
||||
} else if (strategy.equals(PluginDisableStrategy.NONE)) {
|
||||
if (dependantPlugin.isEnabled()) {
|
||||
aDependantNotDisabled = dependant;
|
||||
break; // in this case, we don't need to continue with the rest of its dependants
|
||||
if (dependentPlugin.isEnabled()) {
|
||||
aDependentNotDisabled = dependent;
|
||||
break; // in this case, we don't need to continue with the rest of its dependents
|
||||
}
|
||||
|
||||
// If the strategy is not none and this dependant plugin is not enabled, add it as already disabled
|
||||
} else if (!dependantPlugin.isEnabled()) {
|
||||
PluginDisableResult dependantStatus = new PluginDisableResult(dependant, ALREADY_DISABLED, Messages.PluginWrapper_Already_Disabled(dependant));
|
||||
result.addDependantDisableStatus(dependantStatus);
|
||||
// If the strategy is not none and this dependent plugin is not enabled, add it as already disabled
|
||||
} else if (!dependentPlugin.isEnabled()) {
|
||||
PluginDisableResult dependentStatus = new PluginDisableResult(dependent, ALREADY_DISABLED, Messages.PluginWrapper_Already_Disabled(dependent));
|
||||
result.addDependentDisableStatus(dependentStatus);
|
||||
|
||||
// If the strategy is not none and this dependant plugin is enabled, disable it
|
||||
// If the strategy is not none and this dependent plugin is enabled, disable it
|
||||
} else {
|
||||
// As there is no cycles in the plugin dependencies, the recursion shouldn't be infinite. The
|
||||
// strategy used is the same for its dependants plugins
|
||||
PluginDisableResult dependantResult = dependantPlugin.disable(strategy);
|
||||
PluginDisableStatus dependantStatus = dependantResult.status;
|
||||
// strategy used is the same for its dependents plugins
|
||||
PluginDisableResult dependentResult = dependentPlugin.disable(strategy);
|
||||
PluginDisableStatus dependentStatus = dependentResult.status;
|
||||
|
||||
// If something wrong happened, flag this dependant plugin to set the plugin later as not-disabled due
|
||||
// to its dependants plugins.
|
||||
if (ERROR_DISABLING.equals(dependantStatus) || NOT_DISABLED_DEPENDANTS.equals(dependantStatus)) {
|
||||
aDependantNotDisabled = dependant;
|
||||
break; // we found a dependant plugin enabled, stop looking for dependant plugins to disable.
|
||||
// If something wrong happened, flag this dependent plugin to set the plugin later as not-disabled due
|
||||
// to its dependents plugins.
|
||||
if (ERROR_DISABLING.equals(dependentStatus) || NOT_DISABLED_DEPENDANTS.equals(dependentStatus)) {
|
||||
aDependentNotDisabled = dependent;
|
||||
break; // we found a dependent plugin enabled, stop looking for dependent plugins to disable.
|
||||
}
|
||||
result.addDependantDisableStatus(dependantResult);
|
||||
result.addDependentDisableStatus(dependentResult);
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no enabled-dependant plugin, disable this plugin and add it to the result
|
||||
if (aDependantNotDisabled == null) {
|
||||
// If there is no enabled-dependent plugin, disable this plugin and add it to the result
|
||||
if (aDependentNotDisabled == null) {
|
||||
try {
|
||||
this.disableWithoutCheck();
|
||||
result.setMessage(Messages.PluginWrapper_Plugin_Disabled(shortName));
|
||||
@@ -665,30 +712,30 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
result.setMessage(Messages.PluginWrapper_Error_Disabling(shortName, io.toString()));
|
||||
result.setStatus(ERROR_DISABLING);
|
||||
}
|
||||
// if there is yet some not disabled dependant plugin (only possible with none strategy), this plugin cannot
|
||||
// if there is yet some not disabled dependent plugin (only possible with none strategy), this plugin cannot
|
||||
// be disabled.
|
||||
} else {
|
||||
result.setMessage(Messages.PluginWrapper_Plugin_Has_Dependant(shortName, aDependantNotDisabled, strategy));
|
||||
result.setMessage(Messages.PluginWrapper_Plugin_Has_Dependent(shortName, aDependentNotDisabled, strategy));
|
||||
result.setStatus(NOT_DISABLED_DEPENDANTS);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Set<String> dependantsToCheck(PluginDisableStrategy strategy) {
|
||||
Set<String> dependantsToCheck;
|
||||
private Set<String> dependentsToCheck(PluginDisableStrategy strategy) {
|
||||
Set<String> dependentsToCheck;
|
||||
switch (strategy) {
|
||||
case ALL:
|
||||
// getDependants returns all the dependant plugins, mandatory or optional.
|
||||
dependantsToCheck = this.getDependants();
|
||||
// getDependents returns all the dependent plugins, mandatory or optional.
|
||||
dependentsToCheck = this.getDependents();
|
||||
break;
|
||||
default:
|
||||
// It includes MANDATORY, NONE:
|
||||
// with NONE, the process only fail if mandatory dependant plugins exists
|
||||
// As of getDependants has all the dependants, we get the difference between them and only the optionals
|
||||
dependantsToCheck = Sets.difference(this.getDependants(), this.getOptionalDependants());
|
||||
// with NONE, the process only fail if mandatory dependent plugins exists
|
||||
// As of getDependents has all the dependents, we get the difference between them and only the optionals
|
||||
dependentsToCheck = Sets.difference(this.getDependents(), this.getOptionalDependents());
|
||||
}
|
||||
return dependantsToCheck;
|
||||
return dependentsToCheck;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1001,13 +1048,13 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of the disablement of a plugin and its dependants plugins.
|
||||
* The result of the disablement of a plugin and its dependents plugins.
|
||||
*/
|
||||
public static class PluginDisableResult {
|
||||
private String plugin;
|
||||
private PluginDisableStatus status;
|
||||
private String message;
|
||||
private Set<PluginDisableResult> dependantsDisableStatus = new HashSet<>();
|
||||
private Set<PluginDisableResult> dependentsDisableStatus = new HashSet<>();
|
||||
|
||||
public PluginDisableResult(String plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -1052,12 +1099,12 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Set<PluginDisableResult> getDependantsDisableStatus() {
|
||||
return dependantsDisableStatus;
|
||||
public Set<PluginDisableResult> getDependentsDisableStatus() {
|
||||
return dependentsDisableStatus;
|
||||
}
|
||||
|
||||
public void addDependantDisableStatus(PluginDisableResult dependantDisableStatus) {
|
||||
dependantsDisableStatus.add(dependantDisableStatus);
|
||||
public void addDependentDisableStatus(PluginDisableResult dependentDisableStatus) {
|
||||
dependentsDisableStatus.add(dependentDisableStatus);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1132,7 +1179,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
archive.delete();
|
||||
|
||||
// Redo who depends on who.
|
||||
jenkins.getPluginManager().resolveDependantPlugins();
|
||||
jenkins.getPluginManager().resolveDependentPlugins();
|
||||
|
||||
return HttpResponses.redirectViaContextPath("/pluginManager/installed"); // send back to plugin manager
|
||||
}
|
||||
|
||||
@@ -325,8 +325,8 @@ public abstract class Proc {
|
||||
// see https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors
|
||||
// problems like that shows up as infinite wait in join(), which confuses great many users.
|
||||
// So let's do a timed wait here and try to diagnose the problem
|
||||
if (copier!=null) copier.join(10*1000);
|
||||
if(copier2!=null) copier2.join(10*1000);
|
||||
if (copier!=null) copier.join(TimeUnit.SECONDS.toMillis(10));
|
||||
if(copier2!=null) copier2.join(TimeUnit.SECONDS.toMillis(10));
|
||||
if((copier!=null && copier.isAlive()) || (copier2!=null && copier2.isAlive())) {
|
||||
// looks like handles are leaking.
|
||||
// closing these handles should terminate the threads.
|
||||
|
||||
@@ -47,6 +47,7 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.CheckForNull;
|
||||
import jenkins.model.Jenkins;
|
||||
@@ -85,7 +86,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
|
||||
* Holds a default TCP connect timeout set on all connections returned from this class,
|
||||
* note this is value is in milliseconds, it's passed directly to {@link URLConnection#setConnectTimeout(int)}
|
||||
*/
|
||||
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = SystemProperties.getInteger("hudson.ProxyConfiguration.DEFAULT_CONNECT_TIMEOUT_MILLIS", 20 * 1000);
|
||||
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = SystemProperties.getInteger("hudson.ProxyConfiguration.DEFAULT_CONNECT_TIMEOUT_MILLIS", (int)TimeUnit.SECONDS.toMillis(20));
|
||||
|
||||
public final String name;
|
||||
public final int port;
|
||||
@@ -395,7 +396,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
|
||||
GetMethod method = null;
|
||||
try {
|
||||
method = new GetMethod(testUrl);
|
||||
method.getParams().setParameter("http.socket.timeout", DEFAULT_CONNECT_TIMEOUT_MILLIS > 0 ? DEFAULT_CONNECT_TIMEOUT_MILLIS : new Integer(30 * 1000));
|
||||
method.getParams().setParameter("http.socket.timeout", DEFAULT_CONNECT_TIMEOUT_MILLIS > 0 ? DEFAULT_CONNECT_TIMEOUT_MILLIS : TimeUnit.SECONDS.toMillis(30));
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
if (Util.fixEmptyAndTrim(name) != null && !isNoProxyHost(host, noProxyHost)) {
|
||||
|
||||
@@ -91,7 +91,6 @@ import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
/**
|
||||
@@ -1464,9 +1463,9 @@ public class Util {
|
||||
public static int permissionsToMode(Set<PosixFilePermission> permissions) {
|
||||
PosixFilePermission[] allPermissions = PosixFilePermission.values();
|
||||
int result = 0;
|
||||
for (int i = 0; i < allPermissions.length; i++) {
|
||||
for (PosixFilePermission allPermission : allPermissions) {
|
||||
result <<= 1;
|
||||
result |= permissions.contains(allPermissions[i]) ? 1 : 0;
|
||||
result |= permissions.contains(allPermission) ? 1 : 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ public class DisablePluginCommand extends CLICommand {
|
||||
@Option(name = "-restart", aliases = "-r", usage = "Restart Jenkins after disabling plugins.")
|
||||
private boolean restart;
|
||||
|
||||
@Option(name = "-strategy", aliases = "-s", metaVar = "strategy", usage = "How to process the dependant plugins. \n" +
|
||||
"- none: if a mandatory dependant plugin exists and it is enabled, the plugin cannot be disabled (default value).\n" +
|
||||
"- mandatory: all mandatory dependant plugins are also disabled, optional dependant plugins remain enabled.\n" +
|
||||
"- all: all dependant plugins are also disabled, no matter if its dependency is optional or mandatory.")
|
||||
@Option(name = "-strategy", aliases = "-s", metaVar = "strategy", usage = "How to process the dependent plugins. \n" +
|
||||
"- none: if a mandatory dependent plugin exists and it is enabled, the plugin cannot be disabled (default value).\n" +
|
||||
"- mandatory: all mandatory dependent plugins are also disabled, optional dependent plugins remain enabled.\n" +
|
||||
"- all: all dependent plugins are also disabled, no matter if its dependency is optional or mandatory.")
|
||||
private String strategy = PluginWrapper.PluginDisableStrategy.NONE.toString();
|
||||
|
||||
@Option(name = "-quiet", aliases = "-q", usage = "Be quiet, print only the error messages")
|
||||
@@ -140,10 +140,10 @@ public class DisablePluginCommand extends CLICommand {
|
||||
}
|
||||
|
||||
printIndented(indent, Messages.DisablePluginCommand_StatusMessage(oneResult.getPlugin(), oneResult.getStatus(), oneResult.getMessage()));
|
||||
if (oneResult.getDependantsDisableStatus().size() > 0) {
|
||||
if (oneResult.getDependentsDisableStatus().size() > 0) {
|
||||
indent += INDENT_SPACE;
|
||||
for (PluginWrapper.PluginDisableResult oneDependantResult : oneResult.getDependantsDisableStatus()) {
|
||||
printResult(oneDependantResult, indent);
|
||||
for (PluginWrapper.PluginDisableResult oneDependentResult : oneResult.getDependentsDisableStatus()) {
|
||||
printResult(oneDependentResult, indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,9 +163,9 @@ public class DisablePluginCommand extends CLICommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* Restart if this particular result of the disablement of a plugin and its dependant plugins (depending on the
|
||||
* Restart if this particular result of the disablement of a plugin and its dependent plugins (depending on the
|
||||
* strategy used) has a plugin disablexd.
|
||||
* @param oneResult the result of a plugin (and its dependants).
|
||||
* @param oneResult the result of a plugin (and its dependents).
|
||||
* @return true if it end up in restarting jenkins.
|
||||
*/
|
||||
private boolean restartIfNecessary(PluginWrapper.PluginDisableResult oneResult) throws RestartNotSupportedException {
|
||||
@@ -175,9 +175,9 @@ public class DisablePluginCommand extends CLICommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (oneResult.getDependantsDisableStatus().size() > 0) {
|
||||
for (PluginWrapper.PluginDisableResult oneDependantResult : oneResult.getDependantsDisableStatus()) {
|
||||
if (restartIfNecessary(oneDependantResult)) {
|
||||
if (oneResult.getDependentsDisableStatus().size() > 0) {
|
||||
for (PluginWrapper.PluginDisableResult oneDependentResult : oneResult.getDependentsDisableStatus()) {
|
||||
if (restartIfNecessary(oneDependentResult)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class DisablePluginCommand extends CLICommand {
|
||||
* Calculate the result code of the full process based in what went on during the process
|
||||
* @param results he list of results for the disablement of each plugin
|
||||
* @return the status code. 0 if all plugins disabled. {@link #RETURN_CODE_NOT_DISABLED_DEPENDANTS} if some
|
||||
* dependant plugin is not disabled (with strategy NONE), {@link #RETURN_CODE_NO_SUCH_PLUGIN} if some passed
|
||||
* dependent plugin is not disabled (with strategy NONE), {@link #RETURN_CODE_NO_SUCH_PLUGIN} if some passed
|
||||
* plugin doesn't exist. Whatever happens first.
|
||||
*/
|
||||
private int getResultCode(List<PluginWrapper.PluginDisableResult> results) {
|
||||
@@ -208,7 +208,7 @@ public class DisablePluginCommand extends CLICommand {
|
||||
|
||||
/**
|
||||
* Calculate the result code of the disablement of one plugin based in what went on during the process of this one
|
||||
* and its dependant plugins.
|
||||
* and its dependent plugins.
|
||||
* @param result the result of the disablement of this plugin
|
||||
* @return the status code
|
||||
*/
|
||||
@@ -223,8 +223,8 @@ public class DisablePluginCommand extends CLICommand {
|
||||
}
|
||||
|
||||
if (returnCode == 0) {
|
||||
for (PluginWrapper.PluginDisableResult oneDependantResult : result.getDependantsDisableStatus()) {
|
||||
returnCode = getResultCode(oneDependantResult);
|
||||
for (PluginWrapper.PluginDisableResult oneDependentResult : result.getDependentsDisableStatus()) {
|
||||
returnCode = getResultCode(oneDependentResult);
|
||||
if (returnCode != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
*/
|
||||
package hudson.cli.handlers;
|
||||
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
@@ -5,12 +5,8 @@ import java.io.EOFException;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.WebApp;
|
||||
import org.kohsuke.stapler.compression.CompressionFilter;
|
||||
import org.kohsuke.stapler.compression.UncaughtExceptionHandler;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -44,4 +44,3 @@
|
||||
*/
|
||||
package hudson.init;
|
||||
|
||||
import org.jvnet.hudson.reactor.Task;
|
||||
@@ -54,7 +54,6 @@ import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -156,7 +156,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match.booleanValue()) {
|
||||
if (match) {
|
||||
// most specific logger matches, so publish
|
||||
super.publish(record);
|
||||
}
|
||||
@@ -215,14 +215,14 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
|
||||
public Boolean matches(LogRecord r) {
|
||||
boolean levelSufficient = r.getLevel().intValue() >= level;
|
||||
if (name.length() == 0) {
|
||||
return Boolean.valueOf(levelSufficient); // include if level matches
|
||||
return levelSufficient; // include if level matches
|
||||
}
|
||||
String logName = r.getLoggerName();
|
||||
if(logName==null || !logName.startsWith(name))
|
||||
return null; // not in the domain of this logger
|
||||
String rest = logName.substring(name.length());
|
||||
if (rest.startsWith(".") || rest.length()==0) {
|
||||
return Boolean.valueOf(levelSufficient); // include if level matches
|
||||
return levelSufficient; // include if level matches
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ package hudson.logging;
|
||||
|
||||
import hudson.FeedAdapter;
|
||||
import hudson.Functions;
|
||||
import hudson.PluginManager;
|
||||
import hudson.init.Initializer;
|
||||
import static hudson.init.InitMilestone.PLUGINS_PREPARED;
|
||||
import hudson.model.AbstractModelObject;
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import jenkins.model.Configuration;
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import hudson.model.queue.Tasks;
|
||||
import hudson.model.queue.WorkUnit;
|
||||
import hudson.security.ACLContext;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.security.Permission;
|
||||
import hudson.security.ACL;
|
||||
import hudson.util.AlternativeUiTextProvider;
|
||||
import hudson.util.AlternativeUiTextProvider.Message;
|
||||
|
||||
@@ -25,7 +25,6 @@ package hudson.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import hudson.console.ModelHyperlinkNote;
|
||||
|
||||
@@ -31,7 +31,6 @@ import hudson.Extension;
|
||||
import hudson.Launcher.ProcStarter;
|
||||
import hudson.slaves.Cloud;
|
||||
import jenkins.security.stapler.StaplerDispatchable;
|
||||
import jenkins.util.SystemProperties;
|
||||
import hudson.Util;
|
||||
import hudson.cli.declarative.CLIResolver;
|
||||
import hudson.console.AnnotatedLargeText;
|
||||
|
||||
@@ -6,6 +6,7 @@ import hudson.ExtensionPoint;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ public abstract class ComputerPinger implements ExtensionPoint {
|
||||
public static class BuiltInComputerPinger extends ComputerPinger {
|
||||
@Override
|
||||
public boolean isReachable(InetAddress ia, int timeout) throws IOException {
|
||||
return ia.isReachable(timeout * 1000);
|
||||
return ia.isReachable((int)TimeUnit.SECONDS.toMillis(timeout));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,10 +339,9 @@ public class DependencyGraph implements Comparator<AbstractProject> {
|
||||
set = new ArrayList<DependencyGroup>();
|
||||
map.put(key,set);
|
||||
}
|
||||
for (ListIterator<DependencyGroup> it = set.listIterator(); it.hasNext();) {
|
||||
DependencyGroup d = it.next();
|
||||
for (DependencyGroup d : set) {
|
||||
// Check for existing edge that connects the same two projects:
|
||||
if (d.getUpstreamProject()==dep.getUpstreamProject() && d.getDownstreamProject()==dep.getDownstreamProject()) {
|
||||
if (d.getUpstreamProject() == dep.getUpstreamProject() && d.getDownstreamProject() == dep.getDownstreamProject()) {
|
||||
d.add(dep);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ import org.apache.commons.io.IOUtils;
|
||||
import static hudson.util.QuotedStringTokenizer.*;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import java.io.File;
|
||||
|
||||
@@ -46,11 +46,11 @@ import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jenkins.model.DownloadSettings;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.util.JSONSignatureValidator;
|
||||
import net.sf.json.JSONException;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -92,7 +92,7 @@ public class DownloadService extends PageDecorator {
|
||||
if(Jenkins.getInstance().hasPermission(Jenkins.READ)) {
|
||||
long now = System.currentTimeMillis();
|
||||
for (Downloadable d : Downloadable.all()) {
|
||||
if(d.getDue()<now && d.lastAttempt+10*1000<now) {
|
||||
if(d.getDue()<now && d.lastAttempt+TimeUnit.SECONDS.toMillis(10)<now) {
|
||||
buf.append("<script>")
|
||||
.append("Behaviour.addLoadEvent(function() {")
|
||||
.append(" downloadService.download(")
|
||||
|
||||
@@ -39,7 +39,6 @@ import hudson.util.XStream2;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -29,7 +29,6 @@ import hudson.EnvVars;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.FeedAdapter;
|
||||
import hudson.FilePath;
|
||||
import hudson.PermalinkList;
|
||||
import hudson.Util;
|
||||
import hudson.cli.declarative.CLIResolver;
|
||||
@@ -67,7 +66,6 @@ import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -26,7 +26,6 @@ package hudson.model;
|
||||
import hudson.util.ByteBuffer;
|
||||
import hudson.util.CharSpool;
|
||||
import hudson.util.LineEndNormalizingWriter;
|
||||
import org.apache.commons.fileupload.util.Closeable;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.framework.io.WriterOutputStream;
|
||||
|
||||
@@ -51,6 +51,7 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.List;
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
@@ -376,7 +377,7 @@ public abstract class LoadStatistics {
|
||||
/**
|
||||
* Load statistics clock cycle in milliseconds. Specify a small value for quickly debugging this feature and node provisioning through cloud.
|
||||
*/
|
||||
public static int CLOCK = SystemProperties.getInteger(LoadStatistics.class.getName() + ".clock", 10 * 1000);
|
||||
public static int CLOCK = SystemProperties.getInteger(LoadStatistics.class.getName() + ".clock", (int)TimeUnit.SECONDS.toMillis(10));
|
||||
|
||||
/**
|
||||
* Periodically update the load statistics average.
|
||||
|
||||
@@ -27,7 +27,6 @@ import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.Permission;
|
||||
import hudson.util.FormValidation;
|
||||
import hudson.views.MyViewsTabBar;
|
||||
import hudson.views.ViewsTabBar;
|
||||
@@ -45,7 +44,6 @@ import javax.servlet.ServletException;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.acegisecurity.AccessDeniedException;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
@@ -39,7 +39,6 @@ import hudson.remoting.Callable;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.security.Permission;
|
||||
import hudson.slaves.Cloud;
|
||||
import hudson.slaves.ComputerListener;
|
||||
import hudson.slaves.NodeDescriptor;
|
||||
|
||||
@@ -8,6 +8,7 @@ import javax.annotation.PostConstruct;
|
||||
* {@link Descriptor#load()} method is annotated as {@link PostConstruct} so it get automatically invoked after
|
||||
* constructor and field injection.
|
||||
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
||||
* @since 2.140
|
||||
*/
|
||||
public interface PersistentDescriptor extends Saveable {
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Level.*;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.CheckForNull;
|
||||
@@ -125,7 +124,6 @@ import org.apache.commons.lang.ArrayUtils;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
import org.kohsuke.stapler.StaplerProxy;
|
||||
@@ -1798,7 +1796,9 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
listener.started(getCauses());
|
||||
|
||||
Authentication auth = Jenkins.getAuthentication();
|
||||
if (!auth.equals(ACL.SYSTEM)) {
|
||||
if (auth.equals(ACL.SYSTEM)) {
|
||||
listener.getLogger().println(Messages.Run_running_as_SYSTEM());
|
||||
} else {
|
||||
String id = auth.getName();
|
||||
if (!auth.equals(Jenkins.ANONYMOUS)) {
|
||||
final User usr = User.getById(id, false);
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.sf.json.JSONObject;
|
||||
@@ -115,6 +112,7 @@ public class RunParameterDefinition extends SimpleParameterDefinition {
|
||||
* @return The current filter value, if filter is null, returns ALL
|
||||
* @since 1.517
|
||||
*/
|
||||
@Exported
|
||||
public RunParameterFilter getFilter() {
|
||||
// if filter is null, default to RunParameterFilter.ALL
|
||||
return (null == filter) ? RunParameterFilter.ALL : filter;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class StringParameterValue extends ParameterValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ package hudson.model;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.ExtensionPoint;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import hudson.security.ACLContext;
|
||||
import hudson.util.VersionNumber;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jenkins.security.stapler.StaplerDispatchable;
|
||||
import jenkins.util.SystemProperties;
|
||||
@@ -63,7 +64,6 @@ import jenkins.RestartRequiredException;
|
||||
import jenkins.install.InstallUtil;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.util.io.OnMaster;
|
||||
import jenkins.util.java.JavaUtils;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.acegisecurity.Authentication;
|
||||
@@ -160,7 +160,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
|
||||
/**
|
||||
* Read timeout when downloading plugins, defaults to 1 minute
|
||||
*/
|
||||
private static final int PLUGIN_DOWNLOAD_READ_TIMEOUT = SystemProperties.getInteger(UpdateCenter.class.getName()+".pluginDownloadReadTimeoutSeconds", 60) * 1000;
|
||||
private static final int PLUGIN_DOWNLOAD_READ_TIMEOUT = (int)TimeUnit.SECONDS.toMillis(SystemProperties.getInteger(UpdateCenter.class.getName()+".pluginDownloadReadTimeoutSeconds", 60));
|
||||
|
||||
public static final String PREDEFINED_UPDATE_SITE_ID = "default";
|
||||
|
||||
|
||||
@@ -87,8 +87,6 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
import org.kohsuke.stapler.StaplerProxy;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
@@ -97,8 +95,6 @@ import org.kohsuke.stapler.export.ExportedBean;
|
||||
import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* Represents a user.
|
||||
*
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.CopyOption;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -27,8 +27,7 @@ import hudson.util.FormValidation;
|
||||
import hudson.views.ListViewColumn;
|
||||
import hudson.views.ListViewColumnDescriptor;
|
||||
import hudson.views.ViewJobFilter;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.annotation.CheckForNull;
|
||||
@@ -36,7 +35,6 @@ import javax.annotation.Nonnull;
|
||||
import jenkins.model.DirectlyModifiableTopLevelItemGroup;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jvnet.tiger_types.Types;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
import org.kohsuke.stapler.AncestorInPath;
|
||||
|
||||
@@ -27,7 +27,7 @@ import hudson.model.ItemGroupMixIn;
|
||||
import hudson.model.View;
|
||||
import hudson.model.ViewGroup;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.servlet.ServletException;
|
||||
@@ -145,7 +146,7 @@ public abstract class ViewJob<JobT extends ViewJob<JobT,RunT>, RunT extends Run<
|
||||
reload();
|
||||
} finally {
|
||||
reloadingInProgress = false;
|
||||
nextUpdate = reloadPeriodically ? System.currentTimeMillis()+1000*60 : Long.MAX_VALUE;
|
||||
nextUpdate = reloadPeriodically ? System.currentTimeMillis()+TimeUnit.MINUTES.toMillis(1) : Long.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ public abstract class ViewJob<JobT extends ViewJob<JobT,RunT>, RunT extends Run<
|
||||
// reload operations might eat InterruptException,
|
||||
// so check the status every so often
|
||||
while(reloadQueue.isEmpty() && !terminating())
|
||||
reloadQueue.wait(60*1000);
|
||||
reloadQueue.wait(TimeUnit.MINUTES.toMillis(1));
|
||||
if(terminating())
|
||||
throw new InterruptedException(); // terminate now
|
||||
ViewJob job = reloadQueue.iterator().next();
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
package hudson.model.listeners;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import hudson.AbortException;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.Extension;
|
||||
@@ -35,7 +34,6 @@ import hudson.model.Items;
|
||||
import hudson.security.ACL;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.acegisecurity.AccessDeniedException;
|
||||
|
||||
/**
|
||||
* Receives notifications about CRUD operations of {@link Item}.
|
||||
|
||||
@@ -28,12 +28,10 @@ import hudson.ExtensionListView;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.FilePath;
|
||||
import hudson.Functions;
|
||||
import hudson.Launcher;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Environment;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.JobProperty;
|
||||
import hudson.model.Run;
|
||||
import hudson.model.Run.RunnerAbortedException;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
package hudson.security;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.context.SecurityContext;
|
||||
|
||||
@@ -39,7 +39,6 @@ import jenkins.model.Jenkins;
|
||||
import jenkins.security.stapler.StaplerAccessibleType;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ package hudson.security;
|
||||
import hudson.model.User;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.util.Scrambler;
|
||||
import jenkins.security.ApiTokenProperty;
|
||||
import jenkins.security.SecurityListener;
|
||||
import org.acegisecurity.Authentication;
|
||||
import jenkins.security.BasicApiTokenHelper;
|
||||
|
||||
@@ -50,7 +50,6 @@ import net.sf.json.JSONObject;
|
||||
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
@@ -189,9 +189,9 @@ public class TokenBasedRememberMeServices2 extends TokenBasedRememberMeServices
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cookies.length; i++) {
|
||||
if (ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY.equals(cookies[i].getName())) {
|
||||
return cookies[i].getValue();
|
||||
for (Cookie cookie : cookies) {
|
||||
if (ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY.equals(cookie.getName())) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Establish a periodic ping to keep connections between {@link Slave agents}
|
||||
@@ -184,7 +185,7 @@ public class ChannelPinger extends ComputerListener {
|
||||
public static void setUpPingForChannel(final Channel channel, final SlaveComputer computer, int timeoutSeconds, int intervalSeconds, final boolean analysis) {
|
||||
LOGGER.log(Level.FINE, "setting up ping on {0} with a {1} seconds interval and {2} seconds timeout", new Object[] {channel.getName(), intervalSeconds, timeoutSeconds});
|
||||
final AtomicBoolean isInClosed = new AtomicBoolean(false);
|
||||
final PingThread t = new PingThread(channel, timeoutSeconds * 1000L, intervalSeconds * 1000L) {
|
||||
final PingThread t = new PingThread(channel, TimeUnit.SECONDS.toMillis(timeoutSeconds), TimeUnit.SECONDS.toMillis(intervalSeconds)) {
|
||||
@Override
|
||||
protected void onDead(Throwable cause) {
|
||||
if (analysis) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -210,7 +211,7 @@ public class Channels {
|
||||
public static Channel newJVM(String displayName, TaskListener listener, JVMBuilder vmb, FilePath workDir, ClasspathBuilder classpath) throws IOException {
|
||||
ServerSocket serverSocket = new ServerSocket();
|
||||
serverSocket.bind(new InetSocketAddress("localhost",0));
|
||||
serverSocket.setSoTimeout(10*1000);
|
||||
serverSocket.setSoTimeout((int)TimeUnit.SECONDS.toMillis(10));
|
||||
|
||||
// use -cp + FQCN instead of -jar since remoting.jar can be rebundled (like in the case of the swarm plugin.)
|
||||
vmb.classpath().addJarOf(Channel.class);
|
||||
|
||||
@@ -25,6 +25,7 @@ package hudson.slaves;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.Queue;
|
||||
@@ -70,7 +71,7 @@ public class ComputerRetentionWork extends PeriodicWork {
|
||||
// at the moment I don't trust strategies to wait more than 60 minutes
|
||||
// strategies need to wait at least one minute
|
||||
final long waitInMins = Math.max(1, Math.min(60, c.getRetentionStrategy().check(c)));
|
||||
nextCheck.put(c, startRun + waitInMins*1000*60 /*MINS->MILLIS*/);
|
||||
nextCheck.put(c, startRun + TimeUnit.MINUTES.toMillis(waitInMins));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
||||
@@ -249,7 +249,7 @@ public abstract class RetentionStrategy<T extends Computer> extends AbstractDesc
|
||||
Node checkedNode = c.getNode();
|
||||
if (needExecutor && checkedNode != null && checkedNode.canTake(item) == null) {
|
||||
demandMilliseconds = System.currentTimeMillis() - item.buildableStartMilliseconds;
|
||||
needComputer = demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/;
|
||||
needComputer = demandMilliseconds > TimeUnit.MINUTES.toMillis(inDemandDelay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public abstract class RetentionStrategy<T extends Computer> extends AbstractDesc
|
||||
}
|
||||
} else if (c.isIdle()) {
|
||||
final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
|
||||
if (idleMilliseconds > idleDelay * 1000 * 60 /*MINS->MILLIS*/) {
|
||||
if (idleMilliseconds > TimeUnit.MINUTES.toMillis(idleDelay)) {
|
||||
// we've been idle for long enough
|
||||
logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle for {1}",
|
||||
new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)});
|
||||
|
||||
@@ -31,12 +31,10 @@ import hudson.model.Action;
|
||||
import hudson.model.Project;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.util.ReflectionUtils;
|
||||
import hudson.Launcher;
|
||||
import hudson.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
@@ -154,8 +154,8 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD
|
||||
RunList builds = owner.getBuilds();
|
||||
Set<String> seenUpstreamProjects = new HashSet<String>();
|
||||
|
||||
for ( ListIterator iter = builds.listIterator(); iter.hasNext(); ) {
|
||||
Run build = (Run) iter.next();
|
||||
for (Object build1 : builds) {
|
||||
Run build = (Run) build1;
|
||||
for (FingerprintAction action : build.getActions(FingerprintAction.class)) {
|
||||
for (AbstractProject key : action.getDependencies().keySet()) {
|
||||
if (key == owner) {
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -60,7 +61,6 @@ import antlr.ANTLRException;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import hudson.model.Items;
|
||||
import jenkins.model.ParameterizedJobMixIn;
|
||||
import org.jenkinsci.Symbol;
|
||||
@@ -216,7 +216,7 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
|
||||
}
|
||||
|
||||
public long getInitialDelay() {
|
||||
return MIN - (Calendar.getInstance().get(Calendar.SECOND) * 1000);
|
||||
return MIN - TimeUnit.SECONDS.toMillis(Calendar.getInstance().get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
public void doRun() {
|
||||
|
||||
@@ -273,7 +273,7 @@ public abstract class FormFieldValidator {
|
||||
protected boolean findText(BufferedReader in, String literal) throws IOException {
|
||||
String line;
|
||||
while((line=in.readLine())!=null)
|
||||
if(line.indexOf(literal)!=-1)
|
||||
if(line.contains(literal))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ public abstract class FormValidation extends IOException implements HttpResponse
|
||||
protected boolean findText(BufferedReader in, String literal) throws IOException {
|
||||
String line;
|
||||
while((line=in.readLine())!=null)
|
||||
if(line.indexOf(literal)!=-1)
|
||||
if(line.contains(literal))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.File;
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.ListIterator;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package hudson.util;
|
||||
|
||||
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
|
||||
import com.thoughtworks.xstream.converters.basic.StringConverter;
|
||||
import org.apache.commons.collections.map.LRUMap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LRUStringConverter extends AbstractSingleValueConverter {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -92,16 +93,6 @@ public class MultipartFormDataParser implements AutoCloseable {
|
||||
}
|
||||
|
||||
String[] parts = contentType.split(";");
|
||||
if (parts.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
if ("multipart/form-data".equals(parts[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return ArrayUtils.contains(parts, "multipart/form-data");
|
||||
}
|
||||
}
|
||||
@@ -70,10 +70,9 @@ public class NoOverlapCategoryAxis extends CategoryAxis {
|
||||
Rectangle2D r = null;
|
||||
|
||||
int categoryIndex = 0;
|
||||
Iterator iterator = ticks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
for (Object tick1 : ticks) {
|
||||
|
||||
CategoryTick tick = (CategoryTick) iterator.next();
|
||||
CategoryTick tick = (CategoryTick) tick1;
|
||||
g2.setFont(getTickLabelFont(tick.getCategory()));
|
||||
g2.setPaint(getTickLabelPaint(tick.getCategory()));
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.SortedMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -550,7 +551,7 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
|
||||
}
|
||||
|
||||
// after that wait for it to cease to exist
|
||||
long deadline = System.nanoTime() + softKillWaitSeconds * 1000000000;
|
||||
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(softKillWaitSeconds);
|
||||
int sleepTime = 10; // initially we sleep briefly, then sleep up to 1sec
|
||||
do {
|
||||
if (!p.isRunning()) {
|
||||
@@ -759,7 +760,7 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
|
||||
*/
|
||||
public void kill() throws InterruptedException {
|
||||
// after sending SIGTERM, wait for the process to cease to exist
|
||||
long deadline = System.nanoTime() + softKillWaitSeconds * 1000000000;
|
||||
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(softKillWaitSeconds);
|
||||
kill(deadline);
|
||||
}
|
||||
|
||||
@@ -798,7 +799,7 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
|
||||
|
||||
public void killRecursively() throws InterruptedException {
|
||||
// after sending SIGTERM, wait for the processes to cease to exist until the deadline
|
||||
long deadline = System.nanoTime() + softKillWaitSeconds * 1000000000;
|
||||
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(softKillWaitSeconds);
|
||||
killRecursively(deadline);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ import hudson.model.Saveable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -213,8 +212,7 @@ public class RobustReflectionConverter implements Converter {
|
||||
if (mapping != null) {
|
||||
if (mapping.getItemFieldName() != null) {
|
||||
Collection list = (Collection) newObj;
|
||||
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||
Object obj = iter.next();
|
||||
for (Object obj : list) {
|
||||
writeField(fieldName, mapping.getItemFieldName(), mapping.getItemType(), definedIn, obj);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,6 @@ package hudson.util.io;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -30,7 +30,6 @@ import hudson.util.FileVisitor;
|
||||
import hudson.util.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.apache.tools.zip.Zip64Mode;
|
||||
import org.apache.tools.zip.ZipOutputStream;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.List;
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import hudson.model.Queue.Item;
|
||||
import hudson.model.Queue.Task;
|
||||
import jenkins.widgets.HistoryPageFilter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.Set;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,8 +43,6 @@ import javax.tools.FileObject;
|
||||
import javax.tools.StandardLocation;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -6,9 +6,8 @@ import hudson.Functions;
|
||||
import hudson.Util;
|
||||
import hudson.model.AdministrativeMonitor;
|
||||
import hudson.util.jna.Kernel32Utils;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.security.stapler.StaplerDispatchable;
|
||||
@@ -18,7 +17,6 @@ import org.apache.tools.ant.types.FileSet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
@@ -29,7 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import org.jenkinsci.Symbol;
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,6 @@ import com.google.common.base.Function;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
import hudson.Functions;
|
||||
import hudson.Main;
|
||||
import hudson.model.UpdateCenter.DownloadJob.InstallationStatus;
|
||||
import hudson.model.UpdateCenter.DownloadJob.Installing;
|
||||
import hudson.model.UpdateCenter.InstallationJob;
|
||||
|
||||
@@ -28,17 +28,13 @@ import hudson.Functions;
|
||||
import hudson.diagnosis.ReverseProxySetupMonitor;
|
||||
import hudson.model.AdministrativeMonitor;
|
||||
import hudson.model.PageDecorator;
|
||||
import hudson.util.HttpResponses;
|
||||
import hudson.util.HudsonIsLoading;
|
||||
import hudson.util.HudsonIsRestarting;
|
||||
import jenkins.diagnostics.URICheckEncodingMonitor;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.sf.json.JSON;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
|
||||
@@ -3830,7 +3830,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
while (isQuietingDown
|
||||
&& (timeout <= 0 || System.currentTimeMillis() < waitUntil)
|
||||
&& !RestartListener.isAllReady()) {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
||||
}
|
||||
}
|
||||
return new HttpRedirect(".");
|
||||
@@ -3889,7 +3889,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
|
||||
// if the result isn't available in 5 sec, ignore that.
|
||||
// this is a precaution against hang nodes
|
||||
long endTime = System.currentTimeMillis() + 5000;
|
||||
long endTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(5);
|
||||
|
||||
Map<String,Map<String,String>> r = new HashMap<String, Map<String, String>>();
|
||||
for (Entry<String, Future<Map<String, String>>> e : future.entrySet()) {
|
||||
@@ -4246,7 +4246,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
ACL.impersonate(ACL.SYSTEM);
|
||||
|
||||
// give some time for the browser to load the "reloading" page
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
||||
LOGGER.info(String.format("Restarting VM as requested by %s",exitUser));
|
||||
for (RestartListener listener : RestartListener.all())
|
||||
listener.onRestart();
|
||||
@@ -4282,7 +4282,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
servletContext.setAttribute("app",new HudsonIsRestarting());
|
||||
// give some time for the browser to load the "reloading" page
|
||||
LOGGER.info("Restart in 10 seconds");
|
||||
Thread.sleep(10000);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
|
||||
LOGGER.info(String.format("Restarting VM as requested by %s",exitUser));
|
||||
for (RestartListener listener : RestartListener.all())
|
||||
listener.onRestart();
|
||||
@@ -4587,7 +4587,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
if(ALLOWED_RESOURCE_EXTENSIONS.contains(extension)) {
|
||||
URL url = pluginManager.uberClassLoader.getResource(path);
|
||||
if(url!=null) {
|
||||
long expires = MetaClass.NO_CACHE ? 0 : 365L * 24 * 60 * 60 * 1000; /*1 year*/
|
||||
long expires = MetaClass.NO_CACHE ? 0 : TimeUnit.DAYS.toMillis(365);
|
||||
rsp.serveFile(req,url,expires);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package jenkins.model;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.init.InitMilestone;
|
||||
import hudson.init.Initializer;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import hudson.Extension;
|
||||
import hudson.model.UnprotectedRootAction;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import org.apache.commons.codec.Charsets;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
@@ -39,7 +39,6 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
/**
|
||||
|
||||
+8
-8
@@ -149,8 +149,8 @@ public class RegexValidator implements Serializable {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
if (patterns[i].matcher(value).matches()) {
|
||||
for (Pattern pattern : patterns) {
|
||||
if (pattern.matcher(value).matches()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -169,13 +169,13 @@ public class RegexValidator implements Serializable {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
Matcher matcher = patterns[i].matcher(value);
|
||||
for (Pattern pattern : patterns) {
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
if (matcher.matches()) {
|
||||
int count = matcher.groupCount();
|
||||
String[] groups = new String[count];
|
||||
for (int j = 0; j < count; j++) {
|
||||
groups[j] = matcher.group(j+1);
|
||||
groups[j] = matcher.group(j + 1);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
@@ -196,8 +196,8 @@ public class RegexValidator implements Serializable {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
Matcher matcher = patterns[i].matcher(value);
|
||||
for (Pattern pattern : patterns) {
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
if (matcher.matches()) {
|
||||
int count = matcher.groupCount();
|
||||
if (count == 1) {
|
||||
@@ -205,7 +205,7 @@ public class RegexValidator implements Serializable {
|
||||
}
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int j = 0; j < count; j++) {
|
||||
String component = matcher.group(j+1);
|
||||
String component = matcher.group(j + 1);
|
||||
if (component != null) {
|
||||
buffer.append(component);
|
||||
}
|
||||
|
||||
@@ -284,8 +284,8 @@ public class UrlValidator implements Serializable {
|
||||
schemes = DEFAULT_SCHEMES;
|
||||
}
|
||||
allowedSchemes = new HashSet<String>(schemes.length);
|
||||
for(int i=0; i < schemes.length; i++) {
|
||||
allowedSchemes.add(schemes[i].toLowerCase(Locale.ENGLISH));
|
||||
for (String scheme : schemes) {
|
||||
allowedSchemes.add(scheme.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ package jenkins.scm;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Queue;
|
||||
import hudson.model.Result;
|
||||
import hudson.model.Run;
|
||||
import hudson.model.User;
|
||||
|
||||
@@ -50,7 +50,6 @@ import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -31,8 +31,6 @@ import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ package jenkins.security;
|
||||
|
||||
import hudson.Main;
|
||||
import hudson.util.Secret;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
@@ -8,8 +8,6 @@ import org.acegisecurity.userdetails.UserDetailsService;
|
||||
import org.acegisecurity.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
/**
|
||||
* {@link UserDetailsService} for those {@link SecurityRealm}
|
||||
* that doesn't allow query of other users.
|
||||
|
||||
@@ -56,10 +56,10 @@ public class LastGrantedAuthoritiesProperty extends UserProperty {
|
||||
List<GrantedAuthority> grantedAuthorities = new ArrayList<>(roles.length + 1);
|
||||
grantedAuthorities.add(new GrantedAuthorityImpl(authenticatedRole));
|
||||
|
||||
for (int i = 0; i < roles.length; i++){
|
||||
for (String role : roles) {
|
||||
// to avoid having twice that role
|
||||
if(!authenticatedRole.equals(roles[i])){
|
||||
grantedAuthorities.add(new GrantedAuthorityImpl(roles[i]));
|
||||
if (!authenticatedRole.equals(role)) {
|
||||
grantedAuthorities.add(new GrantedAuthorityImpl(role));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import hudson.remoting.Channel;
|
||||
import hudson.remoting.ChannelClosedException;
|
||||
import jenkins.slaves.RemotingVersionInfo;
|
||||
import org.jenkinsci.remoting.RoleChecker;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import hudson.model.queue.Tasks;
|
||||
import hudson.util.DescribableList;
|
||||
import jenkins.model.GlobalConfiguration;
|
||||
import jenkins.model.GlobalConfigurationCategory;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2019, CloudBees, Inc.
|
||||
*
|
||||
* 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.security;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.model.AdministrativeMonitor;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Queue;
|
||||
import hudson.model.queue.QueueListener;
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AuthorizationStrategy;
|
||||
import hudson.security.FullControlOnceLoggedInAuthorizationStrategy;
|
||||
import hudson.security.LegacyAuthorizationStrategy;
|
||||
import hudson.util.HttpResponses;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Display an administrative monitor if we expect {@link QueueItemAuthenticator} to be a useful security measure,
|
||||
* but either it's not present, or potentially badly configured.
|
||||
*/
|
||||
@Extension
|
||||
@Restricted(NoExternalUse.class)
|
||||
public class QueueItemAuthenticatorMonitor extends AdministrativeMonitor {
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
AuthorizationStrategy authorizationStrategy = Jenkins.get().getAuthorizationStrategy();
|
||||
if (authorizationStrategy instanceof AuthorizationStrategy.Unsecured) {
|
||||
return false;
|
||||
}
|
||||
if (authorizationStrategy instanceof LegacyAuthorizationStrategy) {
|
||||
return false;
|
||||
}
|
||||
if (authorizationStrategy instanceof FullControlOnceLoggedInAuthorizationStrategy) {
|
||||
return false;
|
||||
}
|
||||
return !isQueueItemAuthenticatorPresent() || !isQueueItemAuthenticatorConfigured() || isAnyBuildLaunchedAsSystemWithAuthenticatorPresent();
|
||||
}
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doAct(@QueryParameter String redirect, @QueryParameter String dismiss, @QueryParameter String reset) throws IOException {
|
||||
if (redirect != null) {
|
||||
return HttpResponses.redirectTo("https://jenkins.io/redirect/queue-item-security");
|
||||
}
|
||||
if (dismiss != null) {
|
||||
this.disable(true);
|
||||
}
|
||||
if (reset != null) {
|
||||
anyBuildLaunchedAsSystemWithAuthenticatorPresent = false;
|
||||
}
|
||||
return HttpResponses.forwardToPreviousPage();
|
||||
}
|
||||
|
||||
public static boolean isQueueItemAuthenticatorPresent() {
|
||||
// there is no QueueItemAuthenticatorDescriptor; perhaps you need to install authorize-project?
|
||||
return !QueueItemAuthenticatorDescriptor.all().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isQueueItemAuthenticatorConfigured() {
|
||||
// there is no configured QueueItemAuthenticator; perhaps you need to configure it?
|
||||
return !QueueItemAuthenticatorConfiguration.get().getAuthenticators().isEmpty();
|
||||
}
|
||||
|
||||
public boolean isAnyBuildLaunchedAsSystemWithAuthenticatorPresent() {
|
||||
// you configured a QueueItemAuthenticator, but builds are still running as SYSTEM
|
||||
return anyBuildLaunchedAsSystemWithAuthenticatorPresent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.QueueItemAuthenticatorMonitor_DisplayName();
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
@Extension
|
||||
public static class QueueListenerImpl extends QueueListener {
|
||||
@Override
|
||||
public void onLeft(Queue.LeftItem li) {
|
||||
if (li.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX This can probably be done better, unsure what the expected priority order is
|
||||
String displayName = li.getDisplayName();
|
||||
if (displayName == null && li.task != null) {
|
||||
displayName = li.task.getFullDisplayName();
|
||||
}
|
||||
Queue.Executable executable = li.getExecutable();
|
||||
if (displayName == null && executable != null) {
|
||||
displayName = executable.toString();
|
||||
}
|
||||
|
||||
if (!(li.task instanceof Job<?, ?>)) {
|
||||
// Only care about jobs for now -- Do not react to folder scans and similar
|
||||
LOGGER.log(Level.FINE, displayName + " is not a job");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO this is probably not intended to be used as a getter -- seems potentially unstable
|
||||
Authentication buildAuthentication = li.authenticate();
|
||||
boolean buildRunsAsSystem = buildAuthentication == ACL.SYSTEM;
|
||||
if (!buildRunsAsSystem) {
|
||||
LOGGER.log(Level.FINE, displayName + " does not run as SYSTEM");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.log(Level.FINE, displayName + " is running as SYSTEM");
|
||||
if (isQueueItemAuthenticatorConfigured()) {
|
||||
anyBuildLaunchedAsSystemWithAuthenticatorPresent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean anyBuildLaunchedAsSystemWithAuthenticatorPresent = false;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(QueueItemAuthenticatorMonitor.class.getName());
|
||||
}
|
||||
@@ -26,7 +26,6 @@ package jenkins.security;
|
||||
|
||||
import hudson.ExtensionList;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.security.AbstractPasswordBasedSecurityRealm;
|
||||
import hudson.security.SecurityRealm;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ package jenkins.security.apitoken;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AdministrativeMonitor;
|
||||
import hudson.model.User;
|
||||
import hudson.node_monitors.AbstractAsyncNodeMonitorDescriptor;
|
||||
import hudson.util.HttpResponses;
|
||||
import jenkins.security.ApiTokenProperty;
|
||||
import org.jenkinsci.Symbol;
|
||||
@@ -53,7 +52,7 @@ import java.util.stream.Collectors;
|
||||
@Symbol("legacyApiTokenUsage")
|
||||
@Restricted(NoExternalUse.class)
|
||||
public class LegacyApiTokenAdministrativeMonitor extends AdministrativeMonitor {
|
||||
private static final Logger LOGGER = Logger.getLogger(AbstractAsyncNodeMonitorDescriptor.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(LegacyApiTokenAdministrativeMonitor.class.getName());
|
||||
|
||||
public LegacyApiTokenAdministrativeMonitor() {
|
||||
super("legacyApiToken");
|
||||
|
||||
@@ -2,7 +2,6 @@ package jenkins.slaves;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.Util;
|
||||
import hudson.model.Computer;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
@@ -10,7 +9,6 @@ import java.util.Collections;
|
||||
import java.util.logging.Logger;
|
||||
import javax.inject.Inject;
|
||||
import jenkins.AgentProtocol;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.security.HMACConfidentialKey;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.jenkinsci.remoting.engine.JnlpConnectionState;
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
package jenkins.slaves;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.Util;
|
||||
import hudson.model.Computer;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.Collections;
|
||||
import javax.inject.Inject;
|
||||
import jenkins.AgentProtocol;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.util.SystemProperties;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.jenkinsci.remoting.engine.JnlpConnectionState;
|
||||
import org.jenkinsci.remoting.engine.JnlpProtocol3Handler;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
/**
|
||||
* Master-side implementation for JNLP3-connect protocol.
|
||||
|
||||
@@ -25,7 +25,6 @@ package jenkins.telemetry.impl;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.PluginWrapper;
|
||||
import hudson.model.UsageStatistics;
|
||||
import hudson.util.VersionNumber;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.telemetry.Telemetry;
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -546,7 +545,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
|
||||
* separated by the path separator for the system.
|
||||
*/
|
||||
public String getClasspath() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean firstPass = true;
|
||||
Enumeration componentEnum = pathComponents.elements();
|
||||
while (componentEnum.hasMoreElements()) {
|
||||
@@ -1562,8 +1561,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
|
||||
ReflectUtil.newInstance(subClassToLoad,
|
||||
CONSTRUCTOR_ARGS,
|
||||
new Object[] {
|
||||
parent, project, path,
|
||||
Boolean.valueOf(parentFirst)
|
||||
parent, project, path, parentFirst
|
||||
});
|
||||
}
|
||||
return new AntClassLoader(parent, project, path, parentFirst);
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.jvnet.hudson.crypto.SignatureOutputStream;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package jenkins.util;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user