Example usage for com.amazonaws.services.codepipeline.model Artifact getName

List of usage examples for com.amazonaws.services.codepipeline.model Artifact getName

Introduction

In this page you can find the example usage for com.amazonaws.services.codepipeline.model Artifact getName.

Prototype


public String getName() 

Source Link

Document

The artifact's name.

Usage

From source file:jetbrains.buildServer.codepipeline.CodePipelineBuildListener.java

License:Apache License

@NotNull
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");
            }//from   ww  w.  j a  v a  2 s.c  o m
            return files[0];
        }
    }
    throw new IllegalStateException("No output artifact " + artifact.getName() + " (zip, tar, tar.gz) found in "
            + artifactFolder.getAbsolutePath() + " folder");
}