This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
unomi_upgrade.yml
98 lines (84 loc) · 3.07 KB
/
unomi_upgrade.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
type: update
version: 1.5.2
name: Unomi - Upgrade
logo: /images/jahia-logo-70x70.png
id: unomi-upgrade
description:
short: Unomi - Upgrade
onInstall:
# By default we assume it is a (rolling) redeploy only
- setGlobals:
currentDockerTag: ${nodes.cp.first.version}
targetDockerTag: ${nodes.cp.first.version}
# If a version/docker tag was passed as parameter
- if ('${settings.targetVersion.print()}' != ''):
- setGlobals:
targetDockerTag: ${settings.targetVersion}
- script: |-
// forbid upgrade/downgrade if ES version is incompatible
var oldVersion = "${globals.currentDockerTag}";
var newVersion = "${globals.targetDockerTag}";
if ((oldVersion < "1.5.0" && newVersion > "1.5.0") || (oldVersion > "1.5.0" && newVersion < "1.5.0")) {
return {"result": 1, "out": "Incompatible versions"};
}
return {"result": 0, "out": "Upgrade allowed"};
- cmd[cp]: |-
service karaf stop
user: root
- cmd[${nodes.cp.first.id}]: |-
## [Upgrade] - 1/1
exit 0
- env.control.AddContainerEnvVars[*]:
vars: {"UNOMI_VERSION": "${globals.targetDockerTag}"}
- environment.control.ApplyNodeGroupData [cp, es]:
data:
productVersion: ${globals.targetDockerTag}
- api: environment.control.RedeployContainersByGroup
nodeGroup: cp
tag: ${globals.targetDockerTag}
useExistingVolumes: true
skipReinstall: false
isSequential: false
envName: ${env.envName}
- script: |-
var oldVersion = "${globals.currentDockerTag}";
var newVersion = "${globals.targetDockerTag}";
// Check if the upgrade/downgrade require a jahia module upgrade
if ( newVersion == oldVersion || (newVersion > oldVersion && (oldVersion > "1.4.0" || newVersion < "1.4.0")) || (oldVersion > newVersion && (oldVersion < "1.4.0" || newVersion > "1.4.0"))) {
return {"result": 0, "out": "No need to upgrade module on jahia"};
}
jahia_linked = [];
envs = jelastic.environment.control.getenvs("appstore", session)["infos"];
for (i in envs) {
nodeGroups = envs[i]["nodeGroups"];
for (j in nodeGroups) {
if (nodeGroups[j]["envLink"] == "${env.envName}") {
jahia_linked.push(envs[i]["env"]["envName"]);
break;
}
}
}
if (jahia_linked.length == 0) {
return {"result": 0, "out": "No jahia linked"};
}
res = ""
jahia_linked.forEach(
function(jahiaEnvname) {
data = {
"targetAppid": jahiaEnvname,
"settings": {"unomienv": "${env.envName}"},
"manifest": "${baseUrl}/unomi_update_dx.yml"
};
res += res + jelastic.dev.scripting.eval("appstore", session, "InstallApp", data);
}
);
return {"result": 0, "out": "Jahia environments updated " + res};
settings:
fields:
- name: targetVersion
type: string
caption: Target Version
vtype: text
required: false
tooltip: Optional. If you don't specify a version, the current version of the target environment will be selected.