Search in sources :

Example 16 with DeployDetails

use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.

the class GoExtractorTest method deployTestDependencies.

private void deployTestDependencies(Project... projects) throws IOException {
    for (Project project : projects) {
        for (String ext : GO_PACKAGE_EXTENSIONS) {
            File pkgFile = project.projectOrigin.toPath().resolve("v" + project.version + ext).toFile();
            if (!pkgFile.exists())
                continue;
            DeployDetails deployDetails = new DeployDetails.Builder().file(pkgFile).targetRepository(localRepo1).artifactPath(project.getTargetPath(ext)).packageType(DeployDetails.PackageType.GO).build();
            artifactoryManager.upload(deployDetails);
        }
    }
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) File(java.io.File)

Example 17 with DeployDetails

use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.

the class DeployTask method deployArtifacts.

private void deployArtifacts(Set<GradleDeployDetails> allDeployDetails, ArtifactoryManager artifactoryManager, IncludeExcludePatterns patterns, String logPrefix, int minChecksumDeploySizeKb) throws IOException {
    for (GradleDeployDetails detail : allDeployDetails) {
        DeployDetails deployDetails = detail.getDeployDetails();
        String artifactPath = deployDetails.getArtifactPath();
        if (PatternMatcher.pathConflicts(artifactPath, patterns)) {
            log.log(LogLevel.LIFECYCLE, "Skipping the deployment of '" + artifactPath + "' due to the defined include-exclude patterns.");
            continue;
        }
        try {
            ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails, logPrefix, minChecksumDeploySizeKb);
            detail.getDeployDetails().setDeploySucceeded(true);
            detail.getDeployDetails().setSha256(response.getChecksums().getSha256());
        } catch (IOException e) {
            detail.getDeployDetails().setDeploySucceeded(false);
            detail.getDeployDetails().setSha256("");
            throw e;
        }
    }
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse) IOException(java.io.IOException)

Example 18 with DeployDetails

use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.

the class TaskHelperConfigurations method gradleDeployDetails.

private GradleDeployDetails gradleDeployDetails(PublishArtifact artifact, String configuration, @Nullable String artifactPath, @Nullable Set<String> processedFiles) {
    ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(getProject());
    if (publisher == null) {
        return null;
    }
    File file = artifact.getFile();
    if (processedFiles != null && processedFiles.contains(file.getAbsolutePath())) {
        return null;
    }
    if (!file.exists()) {
        throw new GradleException("File '" + file.getAbsolutePath() + "'" + " does not exists, and need to be published!");
    }
    if (processedFiles != null) {
        processedFiles.add(file.getAbsolutePath());
    }
    String revision = getProject().getVersion().toString();
    Map<String, String> extraTokens = new HashMap<>();
    if (StringUtils.isNotBlank(artifact.getClassifier())) {
        extraTokens.put("classifier", artifact.getClassifier());
    }
    String pattern = publisher.getIvyArtifactPattern();
    String gid = getProject().getGroup().toString();
    if (publisher.isM2Compatible()) {
        gid = gid.replace(".", "/");
    }
    DeployDetails.Builder deployDetailsBuilder = new DeployDetails.Builder().file(file).packageType(DeployDetails.PackageType.GRADLE);
    try {
        Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(file, MD5_ALGORITHM, SHA1_ALGORITHM, SHA256_ALGORITHM);
        deployDetailsBuilder.md5(checksums.get(MD5_ALGORITHM)).sha1(checksums.get(SHA1_ALGORITHM)).sha256(SHA256_ALGORITHM);
    } catch (Exception e) {
        throw new GradleException("Failed to calculate checksums for artifact: " + file.getAbsolutePath(), e);
    }
    if (artifactPath == null) {
        artifactPath = IvyPatternHelper.substitute(pattern, gid, getModuleName(), revision, artifact.getName(), artifact.getType(), artifact.getExtension(), configuration, extraTokens, null);
    }
    deployDetailsBuilder.artifactPath(artifactPath);
    deployDetailsBuilder.targetRepository(getTargetRepository(artifactPath, publisher));
    PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifact);
    Map<String, String> propsToAdd = getPropsToAdd(artifactInfo, configuration);
    deployDetailsBuilder.addProperties(propsToAdd);
    DeployDetails details = deployDetailsBuilder.build();
    return new GradleDeployDetails(artifactInfo, details, getProject());
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) PublishArtifactInfo(org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) GradleException(org.gradle.api.GradleException) File(java.io.File)

Example 19 with DeployDetails

use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.

the class GoPublish method deploy.

/**
 * Deploy pkg file and add it as an buildInfo's artifact
 */
private Artifact deploy(ArtifactoryManager artifactoryManager, File deployedFile, String extension) throws Exception {
    String artifactName = version + "." + extension;
    Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(deployedFile, MD5_ALGORITHM, SHA1_ALGORITHM, SHA256_ALGORITHM);
    String remotePath = moduleName + "/@v";
    DeployDetails deployDetails = new DeployDetails.Builder().file(deployedFile).targetRepository(deploymentRepo).addProperties(properties).artifactPath(remotePath + "/" + artifactName).md5(checksums.get(MD5_ALGORITHM)).sha1(checksums.get(SHA1_ALGORITHM)).sha256(checksums.get(SHA256_ALGORITHM)).packageType(DeployDetails.PackageType.GO).build();
    ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails);
    return new ArtifactBuilder(moduleName + ":" + artifactName).md5(response.getChecksums().getMd5()).sha1(response.getChecksums().getSha1()).sha256(response.getChecksums().getSha256()).remotePath(remotePath).build();
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ArtifactoryUploadResponse(org.jfrog.build.client.ArtifactoryUploadResponse) ArtifactBuilder(org.jfrog.build.extractor.builder.ArtifactBuilder)

Example 20 with DeployDetails

use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.

the class BuildDeploymentHelper method prepareDeployableArtifacts.

private Map<String, Set<DeployDetails>> prepareDeployableArtifacts(BuildInfo buildInfo, Map<String, DeployDetails> deployableArtifactBuilders) {
    Map<String, Set<DeployDetails>> deployableArtifactsByModule = new LinkedHashMap<>();
    List<Module> modules = buildInfo.getModules();
    for (Module module : modules) {
        Set<DeployDetails> moduleDeployableArtifacts = new LinkedHashSet<>();
        List<Artifact> artifacts = module.getArtifacts();
        if (artifacts != null) {
            for (Artifact artifact : artifacts) {
                String artifactId = BuildInfoExtractorUtils.getArtifactId(module.getId(), artifact.getName());
                DeployDetails deployable = deployableArtifactBuilders.get(artifactId);
                if (deployable != null) {
                    File file = deployable.getFile();
                    setArtifactChecksums(file, artifact);
                    artifact.setRemotePath(deployable.getArtifactPath());
                    moduleDeployableArtifacts.add(new DeployDetails.Builder().artifactPath(deployable.getArtifactPath()).file(file).md5(artifact.getMd5()).sha1(artifact.getSha1()).sha256(artifact.getSha256()).addProperties(deployable.getProperties()).targetRepository(deployable.getTargetRepository()).packageType(DeployDetails.PackageType.MAVEN).build());
                }
            }
        }
        if (!moduleDeployableArtifacts.isEmpty()) {
            deployableArtifactsByModule.put(module.getId(), moduleDeployableArtifacts);
        }
    }
    return deployableArtifactsByModule;
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) Artifact(org.jfrog.build.extractor.ci.Artifact) Module(org.jfrog.build.extractor.ci.Module) File(java.io.File)

Aggregations

DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)24 File (java.io.File)8 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)7 IOException (java.io.IOException)6 ArtifactBuilder (org.jfrog.build.extractor.builder.ArtifactBuilder)6 ArtifactoryUploadResponse (org.jfrog.build.client.ArtifactoryUploadResponse)4 BuildInfoExtractorUtils.getModuleIdString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString)4 BuildInfoExtractorUtils.getTypeString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString)4 ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)4 IncludeExcludePatterns (org.jfrog.build.extractor.clientConfiguration.IncludeExcludePatterns)4 Artifact (org.jfrog.build.extractor.ci.Artifact)3 ArtifactoryManager (org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager)3 GradleDeployDetails (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)3 RandomAccessFile (java.io.RandomAccessFile)2 Map (java.util.Map)2 Project (org.apache.tools.ant.Project)2 DependencyBuilder (org.jfrog.build.extractor.builder.DependencyBuilder)2 Module (org.jfrog.build.extractor.ci.Module)2 PublishArtifactInfo (org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo)2 Path (java.nio.file.Path)1