How to pass parameter of type 'select' when adding build to queue using Rest api

Im trying to add builds to the queue using REST api with XML format.

- This is an example of the XML format of a 'username' parameter of type text:

<build>
    <buildType id="#{build_config_id1}"/>
    <properties>
        <property name="username" value="value"/>
    </properties>
</build>

The build has successfully started with the exact value I entered for the username parameter.

 

- I have another parameter of type select, which means I have a list of tests to select before running the build.

For the parameter configuration, I enable the Allow multiple selection option and this is the list of items:

110 : System check - All packets types with nominal length
111 : System check - All packets types with biggest length
112 : System check - All packets types with secondary headers
113 : System check - Maximum data
114 : System check - All packets with configurations
115 : System check - All packets types with secondary headers
116 : System check - Maximum data
117 : System check - All packets with configurations

And this is what it looks like in the parameters tab before running the build:

And this is the XML format I was trying to pass:

<build>
   <buildType id="#{build_config_id1}"/>
   <properties>
       <property name="Select_test" value="System check - All packets types with nominal length "/>
        <property name="Select_test" value="System check - All packets types with biggest length "/>
        <property name="Select_test" value="System check - All packets types with secondary headers"/>
        <property name="Select_test" value="System check - Maximum data"/>
        <property name="Select_test" value="System check - All packets with configurations"/>
        <property name="Select_test" value="System check - All packets types with secondary headers"/>
        <property name="Select_test" value="System check - Maximum data"/>
        <property name="Select_test" value="System check - All packets with configurations"/>
   </properties>
</build>

However, the build has started but the test list has not been selected.

So I would like to know how to pass parameters of type 'select'.

 

Thanks in advance

0
2 comments

Hello,

It often helps to start a build manually first, then retrieve it via REST and check how the parameter is defined there. To pass multiple values for multi-select list, you need to specify them as a string with separator (using whatever separator you have defined in the parameter spec - comma, by default). For example, let`s say I have the following values for my select-typed parameter named numbers:

one => 1
two => 2
three => 3

and I need to pass all three values. The following request body will do that:

{
	"buildType": {
		"id": "MyConfigurationID"
	},
	"properties": {
		"property": [
			{
				"name": "numbers",
				"value": "1,2,3"
			}
		]
	}
}
1

Thank you Fedor Rumyantsev for always answering my questions as quickly as possible,

Regarding your reply, I did exactly as you said, I ran the build manually and tried to print the value of the "select_tests" parameter to see how it looks like, and yes the result was as a string with ',' separator.

So I passed the list of tests as a string and separated them with ",". As a result the build was successful.

Thanks again

0

Please sign in to leave a comment.