This repository has been archived by the owner on Apr 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
60 lines (41 loc) · 1.46 KB
/
main.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
function displayUsage() {
console.log("Usage: [-n missingparatertext] url searchparameter buildtypeid [buildtypeid2] [buildtypeid3]" +
"\nurl\t\t in format http://username:[email protected]:port\nbuildTypeId\t from teamcity\n[-n missingparamtertext] : What value to display when the parameter is not defined");
}
var argv = require('minimist')(process.argv.slice(2)),
tcparams = require("./tcparams");
if (typeof argv._ == 'undefined' || argv._.length < 3) {
displayUsage();
return;
}
var user = process.env.TCUSER,
password = process.env.TCPASSWORD;
if(typeof user == 'undefined')
throw "Missing TCUSER environment variables";
if(typeof password == 'undefined')
throw "Missing TCPASSWORD environment variable";
var emptyParameterValue="<NOT FOUND>";
if(typeof argv.n != 'undefined'){
emptyParameterValue = argv.n;
}
function writeCsv() {
var separator = ",",
elements = [];
for (var i = 0; i < arguments.length; i++) {
var value = arguments[i].replace("\"", "'");
elements.push("\"" + value + "\"");
}
console.log(elements.join(separator));
}
var options = {
teamCityHost: argv._[0] ,
buildTypeIds : argv._.slice(2),
parameterNames : [ argv._[1]],
user: user,
password: password
};
tcparams.queryTeamCityParameters(options, function(error, result){
if(error)
throw error;
writeCsv(result.parameterName, result.buildTypeId, result.parameterValue);
});