Search in sources :

Example 1 with ArtifactInfo

use of org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildInfo.ArtifactInfo in project platformlayer by platformlayer.

the class JenkinsCasStore method findArtifact.

@Override
public CasStoreObject findArtifact(Md5Hash hash) throws OpsException {
    try {
        FingerprintInfo fingerprint = client.findByFingerprint(hash.toHex());
        if (fingerprint == null) {
            return null;
        }
        BuildId build = fingerprint.getOriginalBuild();
        if (build == null) {
            build = fingerprint.getFirstUsage();
            if (build == null) {
                log.warn("Cannot find build for fingerprint: " + hash.toHex());
                return null;
            }
        }
        BuildInfo buildInfo = client.findBuildInfo(build);
        if (buildInfo == null) {
            return null;
        }
        String fingerprintFileName = fingerprint.getFileName();
        ArtifactInfo found = buildInfo.findArtifactByFileName(fingerprintFileName);
        if (found == null) {
            log.warn("Could not find artifact: " + fingerprint + " in " + buildInfo);
            return null;
        }
        URI url = found.getArtifactUrl();
        return new JenkinsCasObject(this, hash, url);
    } catch (JenkinsException e) {
        throw new OpsException("Error communicating with Jenkins", e);
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) ArtifactInfo(org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildInfo.ArtifactInfo) BuildId(org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildId) BuildInfo(org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildInfo) FingerprintInfo(org.platformlayer.ops.cas.jenkins.JenkinsClient.FingerprintInfo) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 OpsException (org.platformlayer.ops.OpsException)1 BuildId (org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildId)1 BuildInfo (org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildInfo)1 ArtifactInfo (org.platformlayer.ops.cas.jenkins.JenkinsClient.BuildInfo.ArtifactInfo)1 FingerprintInfo (org.platformlayer.ops.cas.jenkins.JenkinsClient.FingerprintInfo)1