Skip to content

backward compatibility for v < 5.4 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions scripts/add-build-project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,30 @@
url += ".git";
}

var nodeId = parseInt("${nodes.build.first.id}", 10);
var projectId = parseInt("${nodes.build.first.customitem.projects[0].id}", 10);
var envName = "${env.envName}";

if (isNaN(nodeId)) {
var resp = jelastic.env.control.GetEnvInfo(envName, session);
if (resp.result != 0) return resp;
var nodes = resp.nodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeGroup == "build") {
nodeId = nodes[i].id;
var projects = nodes[i].customitem.projects;
if (projects) projectId = projects[0].id;
break;
}
}
}

targetEnv = targetEnv.toString().split(".")[0];
var params = {
name: name,
envName: "${env.envName}",
envName: envName,
env: targetEnv,
nodeId: "${nodes.build.first.id}",
nodeId: nodeId,
session: session,
type: "git",
context: "ROOT",
Expand All @@ -30,7 +48,6 @@
}

//remove the old project
var projectId = parseInt("${nodes.build.first.customitem.projects[0].id}", 10);
if (!isNaN(projectId)) {
var resp = jelastic.env.build.RemoveProject(params.envName, params.session, params.nodeId, projectId);
if (resp.result != 0) return resp;
Expand Down
32 changes: 24 additions & 8 deletions scripts/create-redeploy-script.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.hivext.api.core.utils.Transport;
import com.hivext.api.utils.Random;

var buildEnv = "${env.envName}";

//reading script from URL
var scriptBody = new Transport().get(url)

Expand All @@ -14,10 +16,8 @@
targetEnv = targetEnv.toString().split(".")[0];
scriptBody = scriptBody.replace("${TARGET_ENV}", targetEnv);
scriptBody = scriptBody.replace("${NODE_GROUP}", nodeGroup.toString());
var buildEnv = "${env.envName}";
scriptBody = scriptBody.replace("${BUILD_ENV}", buildEnv);
scriptBody = scriptBody.replace("${BUILD_ENV_APPID}", "${env.appid}");
scriptBody = scriptBody.replace("${BUILD_NODE_ID}", "${nodes.build.first.id}");
scriptBody = scriptBody.replace("${UID}", user.uid.toString());

//getting master node
Expand All @@ -39,16 +39,32 @@
scriptBody = scriptBody.replace("${BUILD}", build.toString());

if (build) {

//getting build node id and project id
var nodeId = parseInt("${nodes.build.first.id}", 10);
var projectId = parseInt("${nodes.build.first.customitem.projects[0].id}", 10);
var projectName = "${nodes.build.first.customitem.projects[0].name}";
if (isNaN(projectId)) {
var project = jelastic.env.control.GetEnvInfo(buildEnv, session).nodes[0].customitem.projects[0];
projectId = project.id;
projectName = project.name;
}

scriptBody = scriptBody.replace("${PROJECT_NAME}", projectName.toString());
if (isNaN(nodeId)) {
var resp = jelastic.env.control.GetEnvInfo(buildEnv, session);
if (resp.result != 0) return resp;
var nodes = resp.nodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeGroup == "build") {
nodeId = nodes[i].id;
var projects = nodes[i].customitem.projects;
if (projects) {
projectId = projects[0].id;
projectName = projects[0].name;
}
break;
}
}
}

scriptBody = scriptBody.replace("${BUILD_NODE_ID}", nodeId.toString());
scriptBody = scriptBody.replace("${PROJECT_ID}", projectId.toString());
scriptBody = scriptBody.replace("${PROJECT_NAME}", projectName.toString());
}

var scriptName = "${env.envName}-${globals.scriptName}";
Expand Down
9 changes: 8 additions & 1 deletion scripts/redeploy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
if (certified) {
if (build){
//resp = jelastic.env.build.BuildProject(buildEnv, signature, nodeId, projectId);
resp = jelastic.env.build.BuildDeployProject(buildEnv, signature, nodeId, projectId, delay);
var params = {
envName: buildEnv,
session: signature,
nodeid: nodeId,
projectid: projectId,
delay: delay
}
resp = jelastic.env.build.BuildDeployProject(params);
} else {
resp = jelastic.env.vcs.Update(targetEnv, signature, 'ROOT', delay);
}
Expand Down