[JENKINS-51913] Prevent archiveArtifacts from displaying a stack trace when no artifacts are found (#6475)

This commit is contained in:
Greg Swift authored and GitHub committed 2022-04-15 06:38:09 -07:00
1 parent 45da1fa0ac
commit 4a38d651fb
3 files changed
+33 -1

No files matched your search

+17 -1
View File
@@ -55,6 +55,7 @@ import hudson.remoting.VirtualChannel;
import hudson.remoting.Which;
import hudson.security.AccessControlled;
import hudson.slaves.WorkspaceList;
import hudson.tasks.ArtifactArchiver;
import hudson.util.DaemonThreadFactory;
import hudson.util.DirScanner;
import hudson.util.ExceptionCatchingThreadFactory;
@@ -3054,6 +3055,21 @@ public final class FilePath implements SerializableOnlyOverRemoting {
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "for script console")
public static int VALIDATE_ANT_FILE_MASK_BOUND = SystemProperties.getInteger(FilePath.class.getName() + ".VALIDATE_ANT_FILE_MASK_BOUND", 10000);
/**
* A dedicated subtype of {@link InterruptedException} for when no matching Ant file mask
* matches are found.
*
* @see ArtifactArchiver
*/
@Restricted(NoExternalUse.class)
public static class FileMaskNoMatchesFoundException extends InterruptedException {
private FileMaskNoMatchesFoundException(String message) {
super(message);
}
private static final long serialVersionUID = 1L;
}
/**
* Validates the ant file mask (like "foo/bar/*.txt, zot/*.jar") against this directory, and try to point out the problem.
* This performs only a bounded number of operations.
@@ -3223,7 +3239,7 @@ public final class FilePath implements SerializableOnlyOverRemoting {
if (ds.getIncludedFilesCount() != 0 || ds.getIncludedDirsCount() != 0) {
return true;
} else {
throw (InterruptedException) new InterruptedException("no matches found within " + bound).initCause(c);
throw (FileMaskNoMatchesFoundException) new FileMaskNoMatchesFoundException("no matches found within " + bound).initCause(c);
}
}
return ds.getIncludedFilesCount() != 0 || ds.getIncludedDirsCount() != 0;