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