in src/main/java/org/jenkinsci/plugins/awsdevicefarm/AWSDeviceFarm.java [800:831]
private File getArtifactFile(String pattern) throws AWSDeviceFarmException {
if (pattern == null || pattern.isEmpty()) {
throw new AWSDeviceFarmException("Must have a non-empty pattern.");
}
try {
// Find glob matches.
FilePath[] matches = workspace.list(pattern);
if (matches == null || matches.length == 0) {
throw new AWSDeviceFarmException(String.format("No Artifacts found using pattern '%s'", pattern));
} else if (matches.length != 1) {
StringBuilder msg = new StringBuilder(String.format("More than one match found for pattern '%s':", pattern));
for (FilePath fp : matches) {
msg.append(String.format("%n\t%s", fp.getRemote()));
}
throw new AWSDeviceFarmException(msg.toString());
}
// Now that we know it's one and only one, take it.
FilePath artifact = matches[0];
writeToLog(String.format("Archiving artifact '%s'", artifact.getName()));
// Copy file (master or slave) to the build artifact directory on the master.
FilePath localArtifact = new FilePath(artifactsDir, artifact.getName());
artifact.copyTo(localArtifact);
return new File(localArtifact.getRemote());
} catch (IOException e) {
throw new AWSDeviceFarmException(String.format("Unable to find artifact %s", e.toString()));
} catch (InterruptedException e) {
throw new AWSDeviceFarmException(String.format("Unable to find artifact %s", e.toString()));
}
}