[JENKINS-71700] avoid stacktrace from artifactarchiver when no artifacts are found (#8908)

[JENKINS-71700] avoid stacktrace in artifactarchiver when no artifacts

When the validateAntFileMask fails because there are too many files or
it takes too long an exception is thrown that was intendend to be
catched in the ArtifactArchiver. But when the build happens on an agent
and not the built-in, this didn't work as the the exception is deeply
wrapped in 2 other exceptions.
As printing this information is of no real help, just catch all
exceptions and print them to the jenkins log but not the build log. Any
other message might just be misleading as one could get the impression
that jenkins stopped after looking at 10000 files and only because of
this no files where archived but this is not the case. At this place the
ArtifactArchiver is just trying to give a hint why it didn't archive
anything.
This commit is contained in:
Markus Winter authored and GitHub committed 2024-02-01 08:56:48 +01:00
1 parent ddf68d3874
commit ef378cc38d
2 files changed
+43 -5

No files matched your search

@@ -31,7 +31,6 @@ import hudson.AbortException;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Functions;
import hudson.Launcher;
import hudson.Util;
import hudson.model.AbstractBuild;
@@ -272,10 +271,8 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep {
if (msg != null) {
listener.getLogger().println(msg);
}
} catch (FilePath.FileMaskNoMatchesFoundException e) {
listener.getLogger().println(e.getMessage());
} catch (Exception e) {
Functions.printStackTrace(e, listener.getLogger());
LOG.log(Level.FINE, e, () -> "Failed to validate ant file mask.");
}
if (allowEmptyArchive) {
listener.getLogger().println(Messages.ArtifactArchiver_NoMatchFound(artifacts));