Skip to content
Permalink
Browse files
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 b585d0da79d8ef2a16a34d61226aac1fac9c13fd
Showing with 25 additions and 3 deletions.
  1. +5 −1 src/main/java/hudson/plugins/s3/S3ArtifactsAction.java
  2. +20 −2 src/main/java/hudson/plugins/s3/S3BucketPublisher.java
@@ -66,6 +66,10 @@ public String getProfile() {
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) {
@@ -109,4 +113,4 @@ private String getDownloadURL(AmazonS3Client client, int signedUrlExpirySeconds,

return client.generatePresignedUrl(request).toExternalForm();
}
}
}
@@ -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 {

0 comments on commit b585d0d

Please sign in to comment.