Merge pull request #289 from ryanjbaxter/release-bundle-distribution-for-commercial
Posting JSON
This commit is contained in:
@@ -17,8 +17,11 @@
|
||||
package releaser.internal.commercial;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jfrog.artifactory.client.Artifactory;
|
||||
import org.jfrog.artifactory.client.ArtifactoryClientBuilder;
|
||||
import org.jfrog.artifactory.client.ArtifactoryRequest;
|
||||
@@ -52,6 +55,12 @@ public class ReleaseBundleCreator {
|
||||
}
|
||||
|
||||
public boolean createReleaseBundle(List<String> repos, String version) throws IOException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> json = new HashMap<>();
|
||||
json.put("release_bundle_name", "TNZ-spring-cloud-netflix-commercial");
|
||||
json.put("release_bundle_version", version);
|
||||
json.put( "source_type", "aql");
|
||||
|
||||
AqlQueryBuilder builder = new AqlQueryBuilder()
|
||||
.item(AqlItem.aqlItem("repo", AqlItem.aqlItem("$eq", "spring-enterprise-maven-prod-local")));
|
||||
|
||||
@@ -60,16 +69,19 @@ public class ReleaseBundleCreator {
|
||||
items[repos.indexOf(repo)] = AqlItem.match("path", repo + "/" + version);
|
||||
}
|
||||
String aql = builder.or(items).asc("path", "name").build();
|
||||
return createReleaseBundle(aql);
|
||||
Map<String, Object> aqlObject = new HashMap<>();
|
||||
aqlObject.put("aql", aql);
|
||||
json.put("source", aqlObject);
|
||||
return createReleaseBundle(objectMapper.writeValueAsString(json));
|
||||
}
|
||||
|
||||
public boolean createReleaseBundle(String aql) throws IOException {
|
||||
log.info("Creating release bundle with AQL [{}]", aql);
|
||||
public boolean createReleaseBundle(String json) throws IOException {
|
||||
log.info("Creating release bundle with JSON [{}]", json);
|
||||
|
||||
ArtifactoryRequest aqlRequest = new ArtifactoryRequestImpl().method(ArtifactoryRequest.Method.POST)
|
||||
.apiUrl("lifecycle/api/v2/release_bundle").addQueryParam("project", "spring")
|
||||
.addHeader("X-JFrog-Signing-Key-Name", "packagesKey").requestType(ArtifactoryRequest.ContentType.JSON)
|
||||
.responseType(ArtifactoryRequest.ContentType.JSON).requestBody(aql);
|
||||
.responseType(ArtifactoryRequest.ContentType.JSON).requestBody(json);
|
||||
ArtifactoryResponse response = artifactory.restCall(aqlRequest);
|
||||
if (!response.isSuccessResponse()) {
|
||||
log.warn("Failed to create release bundle {}", response.getRawBody());
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ReleaserTests {
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions,
|
||||
new ReleaseBundleCreator(SpringCloudReleaserProperties.get()) {
|
||||
@Override
|
||||
public boolean createReleaseBundle(String aql) throws IOException {
|
||||
public boolean createReleaseBundle(String json) throws IOException {
|
||||
return true;
|
||||
}
|
||||
}) {
|
||||
@@ -114,7 +114,7 @@ public class ReleaserTests {
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions,
|
||||
new ReleaseBundleCreator(SpringCloudReleaserProperties.get()) {
|
||||
@Override
|
||||
public boolean createReleaseBundle(String aql) throws IOException {
|
||||
public boolean createReleaseBundle(String json) throws IOException {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user