Context Parameters

The purpose of context parameters is :

  • To provide a list of key/value through json data (at script or at global level).

    For example :

    {
    "test" : [{
            "script" : "pathToMyscript1",
            "param" : {                              // Script context parameters
                "my_cuf" : "value1",
                "property2" : "value2"
            }
        }
    ],
    "param" : {                                      // Global context parameters
        "property2" : "value13",
        "property6" : "value14"
    }
    
  • To transform the parameters as a properties resource and then use it in test script through file to file (using param) converter (in USING clause).

    • For script context parameters the resource is available in the test with : context_script_params.
    • For global context parameters the resource is available in the test with : context_global_params.

In the sample below, in processedCommandFile, ${my_cuf} is replaced by “value1” :

{
    "test" : [{
            "script" : "pathToMyscript1",
            "param" : {
                "my_cuf" : "value1",
                "property2" : "value2"
            }
        }
    ],
    "param" : {
        "property2" : "value13",
        "property6" : "value14"
    }
}

DEFINE $(monShell.sh -param1=${my_cuf}) AS commandFile

CONVERT commandFile TO file (param) USING context_script_params AS processedCommandFile

CONVERT processedCommandFile TO query.shell (query) AS commandLine

EXECUTE local WITH commandLine AS result

context_script_params and context_global_params can be used together but be wary of multiple definitions of the same parameter.

Only the latest parameter sent will be used.

For example :

{
    "test" : [{
            "script" : "pathToMyscript1",
            "param" : {
                "my_cuf" : "value1",
                "property2" : "value2"
            }
        }
    ],
    "param" : {
        "property2" : "value13",
        "property6" : "value14"
    }
}

If you send the parameters in the following order :

CONVERT xmlResource TO file (param) USING context_global_params, context_script_params AS convertedXml

Then : property2 will be replaced by value2.

On the other hand, if you send them in the reverse order :

CONVERT xmlResource TO file (param) USING context_script_params, context_global_params AS convertedXml

Then : property2 will be replaced by value13.

Note

The framework doesn’t prevent you from defining your own SKF resource with those context names. If you ever do it, your context parameters will be overwritten (and a warn is logged).

In the sample below, context_script_params corresponds to sample.properties :

LOAD sample.properties AS sample.file

CONVERT sample.file TO properties (structured) AS context_script_params