Skip to content

Commit

Permalink
[FIXED JENKINS-26901]
Browse files Browse the repository at this point in the history
* rearranged baseDirectory checks to allow non-null baseDirectory to lead to search in workspace directory
  • Loading branch information
barclay-reg committed Feb 11, 2015
1 parent d83af6f commit b91e9d6
Showing 1 changed file with 16 additions and 11 deletions.
Expand Up @@ -36,15 +36,8 @@ public FilePath selectArtifactRecorded(AbstractBuild<?, ?> build, BuildListener
listener.getLogger().println("[WeblogicDeploymentPlugin] - Retrieving artifacts recorded [filtered resources on "+filteredResource+"]...");
List<FilePath> artifactsRecorded = new ArrayList<FilePath>();

//si un repertoire est specifie mais qu'il est inacessible ou invalide on renvoit une erreur
if(StringUtils.isNotBlank(baseDirectory) &&
(! (new File(baseDirectory)).exists() || ! (new File(baseDirectory)).isDirectory() || ! (new File(baseDirectory)).canRead())){
listener.getLogger().println("[WeblogicDeploymentPlugin] - the base directory specified ["+baseDirectory+"] is invalid (doesn't exists or is not a directory or has insufficient privilege). Please check the job configuration");
throw new RuntimeException("The base directory specified ["+baseDirectory+"] is invalid (doesn't exists or is not a directory or has insufficient privilege)");
}

// On parcours le workspace si aucun repertoire de base specifie a la recherche d'un fichier correspondant a l'expression reguliere
if(baseDirectory == null){
if(StringUtils.isBlank(baseDirectory)){
FilePath workspace = build.getWorkspace();
List<FilePath> filesInWorkspace = workspace.list();
for(FilePath file : filesInWorkspace){
Expand All @@ -56,7 +49,18 @@ public FilePath selectArtifactRecorded(AbstractBuild<?, ?> build, BuildListener
}
}
} else {
Collection<?> files = FileUtils.listFiles(new File(baseDirectory), null, true);

File baseDir = new File(baseDirectory);

//si un repertoire est specifie mais qu'il est inacessible ou invalide on renvoit une erreur
if(! baseDir.exists() || ! baseDir.isDirectory() || ! baseDir.canRead()){
listener.getLogger().println("[WeblogicDeploymentPlugin] - the base directory specified ["+baseDirectory+"] is invalid (doesn't exists or is not a directory or has insufficient privilege). Please check the job configuration");
throw new RuntimeException("The base directory specified ["+baseDirectory+"] is invalid (doesn't exists or is not a directory or has insufficient privilege)");
}

Collection<?> files = FileUtils.listFiles(baseDir, null, true);
listener.getLogger().println("List Files, finished with "+ files.size() +"files");

for(File file : (Collection<File>) files){
if(! file.isDirectory() && Pattern.matches(filteredResource, file.getName())){
listener.getLogger().println("[WeblogicDeploymentPlugin] - the following file recorded "+file.getName()+" is eligible.");
Expand All @@ -76,12 +80,13 @@ public FilePath selectArtifactRecorded(AbstractBuild<?, ?> build, BuildListener
}

selectedArtifact = artifactsRecorded.get(0);



// Erreur si l'artifact n'existe pas
if(selectedArtifact == null){
throw new RuntimeException("No artifact to deploy found.");
}

}
return selectedArtifact;
}

Expand Down

0 comments on commit b91e9d6

Please sign in to comment.