lib/api/jenkins.js
function discover(host, cb) {

  const TIMEOUT = 5000;

  var socket = dgram.createSocket('udp4');
  var buffer = new Buffer(text.__('Long live Jenkins!'));
  var parser = new xml2js.Parser();

  socket.on('error', function (err) {
    socket.close();
    cb(err);
  });

  socket.on('message', function (result) {
    socket.close();
    parser.addListener('end', function (result) {
      cb(null, result);
    });
    parser.parseString(result);
  });

  socket.send(buffer, 0, buffer.length, 33848, host, function (err, result) {
    if (err) {
      socket.close();
      cb(err);
    }
  });

  setTimeout(function () {
    cb(new Error(text.__('Unable to find any Jenkins instance on %s', host)));
  }, TIMEOUT);
}
function discover(host, cb) {

  const TIMEOUT = 5000;

  var socket = dgram.createSocket('udp4');
  var buffer = new Buffer(text.__('Long live Jenkins!'));
  var parser = new xml2js.Parser();

  socket.on('error', function (err) {
    socket.close();
    cb(err);
  });

  socket.on('message', function (result) {
    socket.close();
    parser.addListener('end', function (result) {
      cb(null, result);
    });
    parser.parseString(result);
  });

  socket.send(buffer, 0, buffer.length, 33848, host, function (err, result) {
    if (err) {
      socket.close();
      cb(err);
    }
  });

  setTimeout(function () {
    cb(new Error(text.__('Unable to find any Jenkins instance on %s', host)));
  }, TIMEOUT);
}
function discover ( host , cb ) { const TIMEOUT = 5000 ; var socket = dgram . createSocket ( 'udp4' ) ; var buffer = new Buffer ( text . __ ( 'Long live Jenkins!' ) ) ; var parser = new xml2js . Parser ( ) ; socket . on ( 'error' , function ( err ) { socket . close ( ) ; cb ( err ) ; } ) ; socket . on ( 'message' , function ( result ) { socket . close ( ) ; parser . addListener ( 'end' , function ( result ) { cb ( null , result ) ; } ) ; parser . parseString ( result ) ; } ) ; socket . send ( buffer , 0 , buffer . length , 33848 , host , function ( err , result ) { if ( err ) { socket . close ( ) ; cb ( err ) ; } } ) ; setTimeout ( function ( ) { cb ( new Error ( text . __ ( 'Unable to find any Jenkins instance on %s' , host ) ) ) ; } , TIMEOUT ) ; }
Discover whether there's a Jenkins instance running on the specified host.

@param {String} host: hostname
@param {Function} cb: standard cb(err, result) callback
Discover whether there s a Jenkins instance running on the specified host .