-
Notifications
You must be signed in to change notification settings - Fork 0
Composer Parameter file
Composer uses a JSON file to persist user-defined parameters value.
This is the syntax for a JSON file:
{
"repoName": {
"parameterName": "@type String, @desc Defines the value for this specific parameter."
}
}
An example:
{
"repo1": {
"branch": "96a2e5889b9baef42163eb950f3d87032bf62891 refs/pull/4/head",
"simpleParamWithDefault": "myDefault"
}
}
Parameter's name and value are available for REPO hooks (look here).
It allows a user to influence the core behaviour of an REPO.
Hence, an INV Groovy file.
In fact, you could pass a parameter's value through Composer, to the REPO Hook (let's say init
), write a temporary file, then read it from your INV Groovy script file.
A more complete example:
myRepo.json:
{
"my-repo": {
"myParameters": "value"
}
}
myRepo.groovy
repo {
name "my-repo"
...
hooks {
init """
# Do the actual init (git clone, etc)
echo ${myParameters} > temp
"""
}
}
myINV.groovy
inv {
name "my-inv"
...
broadcast { Something } using {
ready {
// $pwd indicates the INV Groovy script location
// It should correspond to the REPO "path" computed or user-defined value.
return new File($pwd, "temo").text
}
}
}
Each JSON files are expected to be located at: ${RepoFileParent}/${RepoFileName}-values.json
.
Per example:
For the Repo Groovy script located at /usr/local/etc/inv/repos/MyRepoFile.groovy
, the JSON parameters file is expected to be located at /usr/local/etc/inv/repos/MyRepoFile-values.json
Extension ".groovy" is not required for the Groovy script file, but ".json" does for the parameters file.