Search in sources :

Example 1 with Distribution

use of org.jfrog.build.api.release.Distribution in project build-info by JFrogDev.

the class DistributeBuildTask method distributeBuild.

@TaskAction
public void distributeBuild() throws IOException {
    validate();
    ArtifactoryPluginConvention convention = (ArtifactoryPluginConvention) getProject().getConvention().getPlugins().get("artifactory");
    DistributerConfig distributerConfig = convention.getDistributerConfig();
    ArtifactoryClientConfiguration clientConf = convention.getClientConfig();
    String buildName = distributerConfig.getBuildName();
    String buildNumber = distributerConfig.getBuildNumber();
    buildName = buildName == null ? clientConf.info.getBuildName() : buildName;
    buildNumber = buildNumber == null ? clientConf.info.getBuildNumber() : buildNumber;
    Distribution distribution = new Distribution(distributerConfig.getPublish(), distributerConfig.getOverrideExistingFiles(), distributerConfig.getGpgPassphrase(), distributerConfig.getAsync(), distributerConfig.getTargetRepoKey(), new ArrayList<>(distributerConfig.getSourceRepoKeys()), distributerConfig.getDryRun());
    try (ArtifactoryManager artifactoryManager = new ArtifactoryManager(distributerConfig.getContextUrl(), distributerConfig.getUsername(), distributerConfig.getPassword(), new GradleClientLogger(getLogger()))) {
        artifactoryManager.distributeBuild(buildName, buildNumber, distribution);
        log.info(String.format("Successfully distributed build %s/%s", clientConf.info.getBuildName(), clientConf.info.getBuildNumber()));
    }
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) GradleClientLogger(org.jfrog.gradle.plugin.artifactory.extractor.GradleClientLogger) ArtifactoryPluginConvention(org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention) ArtifactoryManager(org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager) Distribution(org.jfrog.build.api.release.Distribution) DistributerConfig(org.jfrog.gradle.plugin.artifactory.dsl.DistributerConfig) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskAction (org.gradle.api.tasks.TaskAction)1 Distribution (org.jfrog.build.api.release.Distribution)1 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)1 ArtifactoryManager (org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager)1 ArtifactoryPluginConvention (org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention)1 DistributerConfig (org.jfrog.gradle.plugin.artifactory.dsl.DistributerConfig)1 GradleClientLogger (org.jfrog.gradle.plugin.artifactory.extractor.GradleClientLogger)1