Reputation: 98
I am creating Rally Build Records as part of a TeamCity to Rally integration but havving issues associating a Build with a ChangeSet.
I find a set of related ChangeSets that match a particular criteria and have them in an array of String. I then create a JsonArray object, add these "_ref" strings as JsonPrimatives into the Array, add the array to my create Json object and add it to Rally.
However, what happens is that the build is created but the result has an empty Changeset array.
I have tried including the changesets in the createRequest and also doing an updateRequest but in both cases the response is SUCCESS, there are no errors or warnings reported and the Changeset array is returned as null and re-querying shows all other data as expected but the changeSet array is empty.
Here is the code.
JsonObject obj = new JsonObject();
obj.addProperty("Workspace", def.getWorkspace().getRef());
obj.addProperty("Duration",1.05);
obj.addProperty("Message", "Master 4683 Success");
obj.addProperty("Start", isoFormat.format(new Date()));
obj.addProperty("Status","SUCCESS");
obj.addProperty("Number","4683");
obj.addProperty("Uri", "http://");
obj.addProperty("BuildDefinition",def.getRef());
// changeSets is a ArrayList<String> of "_ref" strings of VALID changesets references.
if (changeSets != null && changeSets.size() > 0) {
JsonArray changeSetList = new JsonArray();
for (String id : changeSets) {
changeSetList.add(new JsonPrimitive(id));
}
obj.add("Changesets", changeSetList);
}
String ref = connector.Create("Build",obj);
connector.Delete(ref, null);
Any ideas?
Upvotes: 0
Views: 512
Reputation:
My thought is that instead of populating your JsonArray with JsonPrimitive's having just the value of the ref, you actually need a JsonObject with a key/value pair of {"_ref", "/changeset/12345678910.js"}. I.E. make a change similar to the following:
// changeSets is a ArrayList<String> of "_ref" strings of VALID changesets references.
if (changeSets != null && changeSets.size() > 0) {
JsonArray changeSetList = new JsonArray();
for (String id : changeSets) {
JsonObject thisChangeset = new JsonObject();
thisChangeset.addProperty("_ref", id);
changeSetList.add(thisChangeset);
}
obj.add("Changesets", changeSetList);
}
And I believe your code should work as expected.
Upvotes: 1