Created
March 5, 2015 14:21
-
-
Save smarigowda/dccf9936b77bfc27d34f to your computer and use it in GitHub Desktop.
A node.js code for using Jenkins REST APIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var fs = require('fs'); | |
var unzip = require('unzip2'); | |
var fstream = require('fstream'); | |
// var handler = function (error, response, body) { | |
// if (!error && response.statusCode == 200) { | |
// console.log(body) // Show the HTML for the Google homepage. | |
// } | |
// } | |
var URL = "http://host:port"; | |
var USER = "xxxx"; | |
var PASS = "xxxx"; | |
var JOBNAME = "JOB_NAME"; | |
var BUILD_NUM = '34'; | |
var reqobj = { | |
url: 'http://host:port/j_acegi_security_check', | |
form: { j_username: USER, j_password: PASS } | |
}; | |
var jenkinsurl = 'http://host:port/plugin/apt-plugin/results/' + JOBNAME + "/builds/" + BUILD_NUM + "/test/" + JOBNAME + "-validation-test_" + BUILD_NUM +".zip"; | |
var request = request.defaults({jar: true}); | |
request.post(reqobj, function () { | |
request(jenkinsurl) | |
.on('end', function() { | |
console.log('end event triggered...'); | |
fs.createReadStream(__dirname + '/zips/results.zip') | |
.pipe(unzip.Extract({ path: __dirname + '/unzip/' }));}) | |
.pipe(fs.createWriteStream(__dirname + '/zips/results.zip')) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
x nx,mc