Skip to content

Commit

Permalink
[Fix JENKINS-13569] Don't look for artifacts if there are none.
Browse files Browse the repository at this point in the history
If "attach archived artifacts" is checked, but the "Archive the artifacts"
post-build option is not, attemping to look for artifacts results in
a NPE.
  • Loading branch information
Joe Hansche committed Apr 27, 2012
1 parent 00f2e55 commit c712a3c
Showing 1 changed file with 16 additions and 5 deletions.
Expand Up @@ -248,6 +248,13 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

boolean result = true;
ConfluenceSite site = getSite();

if (site == null) {
log(listener, "Not publishing because no Confluence Site could be found. " +
"Check your Confluence configuration in system settings.");
return true;
}

ConfluenceSession confluence = site.createSession();
Result buildResult = build.getResult();

Expand Down Expand Up @@ -399,13 +406,17 @@ private String performEdits(final AbstractBuild<?, ?> build, final BuildListener
*/
private List<FilePath> findArtifacts(File artifactsDir) {
ArrayList<FilePath> files = new ArrayList<FilePath>();
for (File f : artifactsDir.listFiles()) {
if (f.isDirectory()) {
files.addAll(findArtifacts(f));
} else if (f.isFile()) {
files.add(new FilePath(f));

if (artifactsDir != null) {
for (File f : artifactsDir.listFiles()) {
if (f.isDirectory()) {
files.addAll(findArtifacts(f));
} else if (f.isFile()) {
files.add(new FilePath(f));
}
}
}

return files;
}

Expand Down

0 comments on commit c712a3c

Please sign in to comment.