Search in sources :

Example 1 with DistributerConfig

use of org.jfrog.gradle.plugin.artifactory.dsl.DistributerConfig 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)

Example 2 with DistributerConfig

use of org.jfrog.gradle.plugin.artifactory.dsl.DistributerConfig in project build-info by JFrogDev.

the class DistributeBuildTask method validate.

private void validate() {
    ArtifactoryPluginConvention convention = (ArtifactoryPluginConvention) getProject().getConvention().getPlugins().get("artifactory");
    DistributerConfig config = convention.getDistributerConfig();
    if (config == null) {
        throw new IllegalArgumentException("The build distribution configuration is missing.");
    }
    if (StringUtils.isEmpty(config.getContextUrl())) {
        throw new IllegalArgumentException("'contextUrl' is a mandatory field for build distribution.");
    }
    if (StringUtils.isEmpty(config.getTargetRepoKey())) {
        throw new IllegalArgumentException("'targetRepoKey' is a mandatory field for build distribution.");
    }
}
Also used : ArtifactoryPluginConvention(org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention) DistributerConfig(org.jfrog.gradle.plugin.artifactory.dsl.DistributerConfig)

Aggregations

ArtifactoryPluginConvention (org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention)2 DistributerConfig (org.jfrog.gradle.plugin.artifactory.dsl.DistributerConfig)2 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 GradleClientLogger (org.jfrog.gradle.plugin.artifactory.extractor.GradleClientLogger)1