This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
target_each
Marcel Kloubert edited this page Nov 1, 2017
·
22 revisions
Iterates over a list of values and deploys for each of them (similar to map).
The following example iterates over the 10 values of My SFTP server
(s. from
).
The target writes its values to the dir
property (s. to
) of Template for My SFTP server
and starts a deployment for each of them.
{
"deploy": {
"targets": [
{
"name": "My SFTP server",
"type": "each",
"description": "Deploys to 'Template for My SFTP server' for each of its values.",
"from": [
"/home/myApp/dev_envs/dev1",
"/home/myApp/dev_envs/dev2",
"/home/myApp/dev_envs/dev3",
"/home/myApp/dev_envs/dev4",
"/home/myApp/dev_envs/dev5",
"/home/myApp/dev_envs/dev6",
"/home/myApp/dev_envs/dev7",
"/home/myApp/dev_envs/dev8",
"/home/myApp/dev_envs/dev9",
"/home/myApp/dev_envs/dev10"
],
"to": [ "dir" ],
"targets": [ "Template for My SFTP server" ]
},
{
"name": "Template for My SFTP server",
"type": "sftp",
"description": "All values of 'My SFTP server' will be written to the 'dir' property of this target.",
"host": "sandbox_srv", "port": 22,
"user": "mkloubert",
"privateKey": "/users/admin/.ssh/id_rsa",
"dir": "You do not need to set this, because it is done by 'My SFTP server'",
"isHidden": true
}
]
}
}
Name | Description |
---|---|
from *
|
A list of (source) values or the path / URL to a JSON file that contains the values. |
to |
One or more property names of the target's settings where to write the values to. |
targets |
One or more target (name) to deploy. |
usePlaceholders |
Use placeholders for the source values or not. Default: (false)
|
* supports placeholders
Instead of defining an array in the from
property, you can define a string with path or URL to an external JSON file with data to iterate over.
{
"deploy": {
"targets": [
{
// ...
"from": "<PATH OR URL TO EXTERNAL JSON FILE>",
// ...
},
// ...
]
}
}
You can load data from local or shared network folder, a HTTP(s) (http://
/ https://
), FTP (ftp://
) or SFTP (sftp://
) server. URLs also supports credentials (if required).
The following TypeScript code demonstrates how the target works in general:
// iterate over "real" targets
// as defined in 'targets'
targets.forEach(currentTarget => {
// set values
// as defined in 'from'
from.forEach(value => {
// clone 'currentTarget'
// to 'clonedTarget'
// fill properties of 'clonedTarget'
// as defined in 'to'
// with 'value'
to.forEach(property => {
clonedTarget[property] = value;
});
// deploy 'clonedTarget'
});
});
let numberOfExecutions = targets.length *
from.length;