Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-40448: add to existing actions for a run
  • Loading branch information
juliantcook authored and Julian Cook committed Dec 14, 2016
1 parent ab3e574 commit b585d0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/main/java/hudson/plugins/s3/S3ArtifactsAction.java
Expand Up @@ -66,6 +66,10 @@ public List<FingerprintRecord> getArtifacts() {
return artifacts;
}

public void addArtifacts(List<FingerprintRecord> artifacts) {
this.artifacts.addAll(artifacts);
}

public void doDownload(final StaplerRequest request, final StaplerResponse response) throws IOException, ServletException {
final String restOfPath = request.getRestOfPath();
if (restOfPath == null) {
Expand Down Expand Up @@ -109,4 +113,4 @@ private String getDownloadURL(AmazonS3Client client, int signedUrlExpirySeconds,

return client.generatePresignedUrl(request).toExternalForm();
}
}
}
22 changes: 20 additions & 2 deletions src/main/java/hudson/plugins/s3/S3BucketPublisher.java
Expand Up @@ -261,15 +261,33 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launc

// don't bother adding actions if none of the artifacts are managed
if (!artifacts.isEmpty()) {
run.addAction(new S3ArtifactsAction(run, profile, artifacts));
run.addAction(new FingerprintAction(run, record));
addS3ArtifactsAction(run, profile, artifacts);
addFingerprintAction(run, record);
}
} catch (AmazonClientException|IOException e) {
e.printStackTrace(listener.error("Failed to upload files"));
run.setResult(constrainResult(Result.UNSTABLE, listener));
}
}

private void addS3ArtifactsAction(Run<?, ?> run, S3Profile profile, List<FingerprintRecord> artifacts) {
S3ArtifactsAction existingAction = run.getAction(S3ArtifactsAction.class);
if (existingAction != null) {
existingAction.addArtifacts(artifacts);
} else {
run.addAction(new S3ArtifactsAction(run, profile, artifacts));
}
}

private void addFingerprintAction(Run<?, ?> run, Map<String, String> record) {
FingerprintAction existingAction = run.getAction(FingerprintAction.class);
if (existingAction != null) {
existingAction.add(record);
} else {
run.addAction(new FingerprintAction(run, record));
}
}

private void printDiagnostics(@Nonnull FilePath ws, PrintStream console, String expanded) throws IOException {
log(Level.WARNING, console, "No file(s) found: " + expanded);
try {
Expand Down

0 comments on commit b585d0d

Please sign in to comment.