Skip to content

Commit

Permalink
[FIXED JENKINS-46180] Log when no files found for archive step.
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Dec 6, 2017
1 parent 1b1342d commit dca630a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Expand Up @@ -37,7 +37,15 @@ protected Void run() throws Exception {
listener.getLogger().println(Messages.ArtifactArchiverStepExecution_Deprecated());
}
Map<String,String> files = ws.act(new ListFiles(step.getIncludes(), step.getExcludes()));
getContext().get(Run.class).pickArtifactManager().archive(ws, getContext().get(Launcher.class), new BuildListenerAdapter(getContext().get(TaskListener.class)), files);
if (files.isEmpty()) {
if (step.getExcludes() != null && !step.getExcludes().equals("")) {
listener.getLogger().println(Messages.ArtifactArchiverStepExecution_NoFilesWithExcludes(step.getIncludes(), step.getExcludes()));
} else {
listener.getLogger().println(Messages.ArtifactArchiverStepExecution_NoFiles(step.getIncludes()));
}
} else {
getContext().get(Run.class).pickArtifactManager().archive(ws, getContext().get(Launcher.class), new BuildListenerAdapter(getContext().get(TaskListener.class)), files);
}
return null;
}

Expand Down
@@ -1 +1,3 @@
ArtifactArchiverStepExecution.Deprecated=The 'archive' step is deprecated, please use 'archiveArtifacts' instead."
ArtifactArchiverStepExecution.Deprecated=The 'archive' step is deprecated, please use 'archiveArtifacts' instead."
ArtifactArchiverStepExecution.NoFiles=No files found to archive for pattern "{0}", continuing.
ArtifactArchiverStepExecution.NoFilesWithExcludes=No files found to archive for pattern "{0}", excluding "{1}", continuing.
Expand Up @@ -48,7 +48,12 @@ public void archive() throws Exception {
@Test public void nonexistent() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {archive 'nonexistent/'}", true));
j.assertBuildStatusSuccess(p.scheduleBuild2(0));
WorkflowRun b = j.buildAndAssertSuccess(p);
j.assertLogContains(Messages.ArtifactArchiverStepExecution_NoFiles("nonexistent/"), b);

p.setDefinition(new CpsFlowDefinition("node { archive includes:'nonexistent/', excludes:'pants' }", true));
WorkflowRun b2 = j.buildAndAssertSuccess(p);
j.assertLogContains(Messages.ArtifactArchiverStepExecution_NoFilesWithExcludes("nonexistent/", "pants"), b2);
}

@Test public void unarchiveDir() throws Exception {
Expand Down

0 comments on commit dca630a

Please sign in to comment.