package net.md_5.bungee.module;

import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
import java.io.IOException;
import java.net.URL;
import lombok.Data;
import net.md_5.bungee.Util;

@Data
public class JenkinsModuleSource implements ModuleSource
{

    @Override
    public void retrieve(ModuleSpec module, ModuleVersion version)
    {
        System.out.println( "Attempting to Jenkins download module " + module.getName() + " v" + version.getBuild() );
        try
        {
            URL website = new URL( "http://ci.md-5.net/job/BungeeCord/" + version.getBuild() + "/artifact/module/" + module.getName().replace( '_', '-' ) + "/target/" + module.getName() + ".jar" );
            Files.copy( ByteStreams.newInputStreamSupplier( ByteStreams.toByteArray( website.openStream() ) ), module.getFile() );
            System.out.println( "Download complete" );
        } catch ( IOException ex )
        {
            System.out.println( "Failed to download: " + Util.exception( ex ) );
        }
    }
}

@@ -151,16 +151,47 @@
 et.URL;%0A
+import java.net.URLConnection;%0A
 import l
@@ -720,24 +720,219 @@
 + %22.jar%22 );%0A
+            URLConnection con = website.openConnection();%0A            // 15 second timeout at various stages%0A            con.setConnectTimeout( 15000 );%0A            con.setReadTimeout( 15000 );%0A%0A
             
@@ -1004,28 +1004,28 @@
 eArray( 
-website.open
+con.getInput
 Stream()

Add connect / read timeout for module download incase Jenkins is down.