KBEC-00367 - Find the sub-properties of a property

Article ID:360032826012
1 minute readKnowledge base

Problem

In some cases, you need to know the sub-properties of a property. It’s not always the case that you know exactly the name of the sub-property. And in some cases, you even don’t know if there are some sub- properties in a property that you can use in your script. So you would like to know the details of the sub- properties of a property.

Solution

There are many ways to get the information about the sub properties of a property. Let’s take the property "/server/settings" as an example.

  1. Using ectool

     ectool getProperties --propertyName "/server/settings" --expand false
  2. Using DSL

     ectool generateDsl /server/settings
  3. Using javascript

     $[/javascript var p = server.settings; var output = ""; for (var subP in p) { output += subP.toString() + "\n"; } output; ]

    The above javascript returns the names of the sub properties as a string which you can use later. This method is not as good as the previous two ways as it does not include the value (it’s a little tricky to return the value when the value refer to other properties. In that case, CloudBees CD (CloudBees Flow) server tries to expand them).