-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-download.js
54 lines (41 loc) · 1.06 KB
/
jenkins-download.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
"use strict";
var gulp = require('gulp');
var jenkinsProperties = require('./jenkins-properties');
var jenkins = require('jenkins')(jenkinsProperties.connection);
var fs = require('fs');
gulp.task('jenkinsDownload', function() {
function getAllJobs() {
jenkins.job.list(function(err, data) {
if (err){
return console.log(err);
}
if (data.length) {
var callback = function(i) {
i++;
if (i < data.length) {
getConfigXml(data[i].name, i, callback);
}
};
getConfigXml(data[0].name, 0, callback);
}
});
}
function getConfigXml(name, index, callback){
jenkins.job.config(name, function(err, data) {
if (err){
return console.log(name + " " + err);
}
saveJobConfigToFile(name, data, index, callback);
});
}
function saveJobConfigToFile(name, content, index, callback) {
fs.writeFile("jobs-download/" + name + ".xml", content, function(err) {
if(err) {
return console.log(name + " " + err);
}
console.log(name + " saved");
callback(index);
});
}
getAllJobs();
});