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()));
}
}
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.");
}
}
Aggregations