forked from mekomsolutions/openmrs-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbahmniapps.js
112 lines (90 loc) · 2.91 KB
/
bahmniapps.js
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
"use strict";
const fs = require("fs");
const path = require("path");
const _ = require("lodash");
const log = require("npmlog");
const model = require("../../utils/model");
const utils = require("../../utils/utils");
const cmns = require("../commons");
const thisType = "bahmniapps";
module.exports = {
getInstance: function() {
var projectBuild = new model.ProjectBuild();
projectBuild.getBuildScript = function() {
return getBuildScript();
};
projectBuild.getDeployScript = function(artifact) {
return getDeployScript(artifact);
};
projectBuild.getArtifact = function(args) {
return getArtifact(args.commitMetadata);
};
projectBuild.postBuildActions = function(args) {
cmns.mavenPostBuildActions(
args.pseudoPom.groupId,
[args.pseudoPom.artifactId],
args.pseudoPom.version
);
};
return projectBuild;
}
};
var getArtifact = function(commitMetadata) {
var artifact = new model.Artifact();
artifact.name = "bahmniapps";
// Bahmni Apps is not version-managed, we infer its version from either the branch name or commit ID.
if (commitMetadata.branchName) {
artifact.version = commitMetadata.branchName;
} else {
artifact.version = commitMetadata.commitId;
}
artifact.buildPath = "./ui/target";
artifact.extension = "zip";
artifact.filename = artifact.name + "." + artifact.extension;
artifact.destFilename = "bahmniapps.zip";
// encapsulating the Maven project
var mavenProject = new model.MavenProject();
mavenProject.groupId = "net.mekomsolutions"; // TODO this should be set through some runtime defaults (Jenkins GP?)
mavenProject.artifactId = artifact.name;
mavenProject.version = artifact.version;
artifact.mavenProject = mavenProject;
return artifact;
};
var getBuildScript = function() {
var script = new model.Script();
script.type = "#!/bin/bash";
script.headComment =
"# Autogenerated script to build projects of type '" + thisType + "'...";
script.body = "cd ./ui\n";
script.body += "./scripts/package.sh\n";
return script;
};
var getDeployScript = function(artifact) {
if (_.isUndefined(artifact)) {
log.error(
"",
"An artifact parameter must be provided to construct the '" +
thisType +
"' deploy script."
);
throw new Error();
}
var script = new model.Script();
script.type = "#!/bin/bash";
script.headComment =
"# Autogenerated script to deploy projects of type '" + thisType + "'...";
script.body = "nexus_envvars=$1 ; . $nexus_envvars\n";
script.body +=
"mvn deploy:deploy-file -DgroupId=net.mekomsolutions -DartifactId=" +
artifact.name +
" -Dversion=" +
artifact.version +
" -Dpackaging=" +
artifact.extension +
" -DrepositoryId=${NEXUS_REPO_ID} -Durl=${ARTIFACT_UPLOAD_URL_" +
thisType +
"} -Dfile=" +
path.join(artifact.buildPath, artifact.destFilename) +
"\n";
return script;
};