xebialabs-community / xlr-xlrelease-plugin

Create and start another XL Release template from a parent template
MIT License
3 stars 14 forks source link

Cannot start release when a variable has multiple values #25

Closed brhahlen closed 6 years ago

brhahlen commented 6 years ago

When trying to start a release, which has multiple values in a variable, the plugin throws the following error:

2017-12-19 15:31:50.297 [scheduler-pool-1-thread-7] {task=Applications/Release530021448/Phase811602231/Task184239269} INFO  c.x.x.s.jython.JythonScriptService - /api/v1/templates?filter=CallMe
2017-12-19 15:31:50.393 [scheduler-pool-1-thread-7] {task=Applications/Release530021448/Phase811602231/Task184239269} INFO  c.x.x.s.jython.JythonScriptService - Found template CallMe with id Applications/Folder85553154/Release778600494
2017-12-19 15:31:50.458 [scheduler-pool-1-thread-7] {task=Applications/Release530021448/Phase811602231/Task184239269} INFO  c.x.x.s.jython.JythonScriptService - Sending content 
        {"title":"Calling123","description":"This is a description","scheduledStartDate":"2017-12-19T23:58:00.000Z","dueDate":"2017-12-19T23:59:00.000Z","plannedDuration":null,"variables":[{"$createdBy": "admin", "requiresValue": true, "$createdAt": "2017-12-19T15:20:07.771+0100", "type": "xlrelease.StringVariable", "$token": "87b9a380-2dad-4d4d-93c6-8c928d8e09e6", "showOnReleaseStart": true, "$lastModifiedBy": "admin", "$lastModifiedAt": "2017-12-19T15:30:40.616+0100", "id": "Applications/Folder85553154/Release778600494/Variable918130674", "value": ""ABC", "DEF", "GHI"", "key": "PROJECTNAME"}],"tags":[],"flag":{"status":"OK"},"templateId":"Folder85553154/Release778600494"}

2017-12-19 15:31:50.498 [qtp1076984738-25] {request=/releases, method=POST, username=admin} ERROR o.jboss.resteasy.resteasy_jaxrs.i18n - RESTEASY002005: Failed executing POST /releases
org.jboss.resteasy.spi.ReaderException: com.fasterxml.jackson.databind.JsonMappingException: Unexpected character ('A' (code 65)): was expecting comma to separate Object entries
 at [Source: HttpInputOverHTTP@6573be61[c=692,q=0,[0]=null,s=STREAM]; line: 2, column: 560]

I have tried the fix proposed in #16, but that doesn't seem to work for this.

brhahlen commented 6 years ago

We need this plugin to create releases, as the official one cannot pass variables into a "wildcarded" release template. (Calling a release template with a variable in the name, as we always know one part, but not the variable part).

Part of the JIRA Query is in the variables, which looks like: PROJECTNAME = "ABC", "DEF", "GHI"

This is being parsed into: ""ABC", "DEF", GHI"" Escaping the " does not work for the JIRA Query

brhahlen commented 6 years ago

So basically: Two releases, Test and CallMe CallMe has the PROJECTNAME variable, and is being called by Test.

The JIRA API requires an "in" statement to look like: project in ("ABC", "DEF", "GHI") Which is why I can't use a list variable for this, as that would show it as: project in (["ABC", "DEF", "GHI"])

brhahlen commented 6 years ago

JIRA Query in XLR is: project in (${PROJECTNAME}) and status = "CLOSED" and type = "Task" and priority = "Minor" (Testing against our JIRA)

brhahlen commented 6 years ago

@jdewinne I could use some help with this, if you please :-)

jdewinne commented 6 years ago

@brhahlen What is the type of the variable you're doing this with?

brhahlen commented 6 years ago

It is a TEXT variable. I have tried to use a list, but the problem is that the formatting of a list is different and doesn't work at all with the JIRA query.

jdewinne commented 6 years ago

But a TEXT variable should work already. Some questions:

brhahlen commented 6 years ago

So, what we are doing: We have a "generic" template that calls upon a specific template, based on the ${APPLICATION_NAME}. This means that we cannot use the built-in Create Release, as that will not give you the option to populate the variables. The application template, has a number of variables, including two for the JIRA Query Tile: ${PROJECTNAME} and ${FIXVERSION}. The JIRA query for the tile looks like: project in (${PROJECTNAME} and fixVersion in (${FIXVERSION}) Said variables need to take the form of: "PRJ1","PRJ2","PRJ3" Now, those two variables already have default values assigned, so we do not necessarily need to pass them to the new release, but it seems that CreateAndStartSubRelease requires them to be passed anyway.

Does that make sense and answer your questions?

jdewinne commented 6 years ago

Get it now. The problem is 2 fold:

I tried reproducing the problem with default values, where it still requires a value to be set in the parent, but couldn't reproduce that. Conclusion: If you can use single quotes in your JQL, we might be able to workout a solution.

brhahlen commented 6 years ago

Using single quotes in JQL is possible, so I think that could be a good solution. I think we have to do some refactoring on our end, but that's not a problem.

jdewinne commented 6 years ago

Can you check v2.2.0. I've introduced a new property for specifying variables that takes a map. The old style is now deprecated. And it should also work with double quotes.

brhahlen commented 6 years ago

This issue is indeed fixed in v2.2.0 (and later versions). Closing this issue.