private File getBuildArtifact()

in aws-codepipeline-agent/src/main/java/jetbrains/buildServer/codepipeline/CodePipelineBuildListener.java [294:318]


  private File getBuildArtifact(@NotNull final Artifact artifact, @NotNull final String pipelineName, @NotNull final File artifactFolder, @NotNull AgentRunningBuild build) {
    final File zip = new File(artifactFolder, artifact.getName() + ".zip");
    if (zip.isFile()) return zip;

    final File tar = new File(artifactFolder, artifact.getName() + ".tar");
    if (tar.exists()) return tar;

    final File tarGz = new File(artifactFolder, artifact.getName() + ".tar.gz");
    if (tarGz.exists()) return tarGz;

    final File tgz = new File(artifactFolder, artifact.getName() + ".tgz");
    if (tgz.exists()) return tgz;

    final File parent = new File(artifactFolder, pipelineName + "/" + artifact.getName());
    if (parent.isDirectory()) {
      final File[] files = parent.listFiles();
      if (files != null && files.length > 0) {
        if (files.length > 1) {
          build.getBuildLogger().warning("Multiple output artifacts detected in " + parent.getAbsolutePath() + ". Will publish only one of them");
        }
        return files[0];
      }
    }
    throw new IllegalStateException("No output artifact " + artifact.getName() + " (zip, tar, tar.gz) found in " + artifactFolder.getAbsolutePath() + " folder");
  }