in src/main/java/com/amazonaws/codepipeline/jenkinsplugin/PublisherCallable.java [66:120]
public Void invoke(final File workspace, final VirtualChannel channel) throws IOException {
final AWSClients awsClients = awsClientFactory.getAwsClient(
model.getAwsAccessKey(),
model.getAwsSecretKey(),
model.getProxyHost(),
model.getProxyPort(),
model.getRegion(),
pluginUserAgentPrefix);
final AWSCodePipelineJobCredentialsProvider credentialsProvider = new AWSCodePipelineJobCredentialsProvider(
model.getJob().getId(), awsClients.getCodePipelineClient());
final AmazonS3 amazonS3 = awsClients.getS3Client(credentialsProvider);
Map<String, String> artifactLocations = new HashMap<>();
final Set<String> artifactNames = getArtifactNamesFromProject(outputs);
if (!artifactNames.isEmpty() && artifactNames.size() != outputs.size()) {
final String message = "Not all locations have artifact name. "
+ "Either enter an artifact name for each location, "
+ "or leave the field blank.";
LoggingHelper.log(listener, message);
throw new IllegalArgumentException(message);
}
if (artifactNames.size() == outputs.size()) {
for (final OutputArtifact outputArtifact : outputs) {
artifactLocations.put(outputArtifact.getArtifactName(), outputArtifact.getLocation());
}
} else {
Iterator<Artifact> artifactIterator = model.getJob().getData().getOutputArtifacts().iterator();
for (final OutputArtifact outputArtifact : outputs) {
final Artifact artifact = artifactIterator.next();
artifactLocations.put(artifact.getName(), outputArtifact.getLocation());
}
}
for (final Artifact artifact : model.getJob().getData().getOutputArtifacts()) {
final String artifactLocation = artifactLocations.get(artifact.getName());
if (artifactLocation != null) {
final Path pathToUpload = CompressionTools.resolveWorkspacePath(workspace, artifactLocation);
if (Files.isDirectory(pathToUpload.toRealPath())) {
uploadDirectory(pathToUpload, artifact, amazonS3);
} else {
uploadFile(pathToUpload.toFile(), artifact, CompressionType.None, amazonS3);
}
} else {
final String message = "No defined output artifact in pipeline matched the jobs output artifact: " + artifact.getName();
LoggingHelper.log(listener, message);
throw new IllegalArgumentException(message);
}
}
return null;
}