load variable from file (.ini, .properties, xml etc)

Comments

2 comments

  • Avatar
    BitRock support

    Hi Ashok,

    We are sorry for the late reply. We have been facing some spam issues and we missed your post.

    You could the <foreach> action to loop over a file that defined variable names and values:

     <readFile>
    <name>variables</name>
    <path>/path/to/file/defining-variables</path>
    </readFile>
    <foreach variables="var val" values="${variables}">
    <actionList>
    <setInstallerVariable>
    <name>${var}</text>
    <value>${val}</value>
    </setInstallerVariable>
    </actionList>
    </foreach>

    The <foreach> loop expect the values to be provided in space-separated (new-line included) pairs, so in case the value contains spaces, it should be quoted or surrounded by curly braces, e.g.:

    var1 value1
    var2 "value 2"
    var3 {value
    "3"}

    Would this work for you? Looking forward to your feedback,
    Alejandro

  • Avatar
    Ashok Mazumder

    I was able to use this:

     <foreach>
    <values>var1 var2 var3</values>
    <variables>variable_name</variables>
    <actionList>
    <propertiesFileGet>
    <file>${build_project_directory}/data.properties</file>
    <key>${variable_name}</key>
    <variable>${variable_name}</variable>
    </propertiesFileGet>
    </actionList>
    </foreach>

    This worked for me only after declaring all these variables are already declared in installer xml. If you try to use some variable which is not declared in installer xml but available in data.properties. variables are not getting evaluated.

Please sign in to leave a comment.