Code Freeze Monitor

Orion SSH2 is a library which implements the SSH-2 protocol in pure Java. It allows one to connect to SSH servers from within Java programs for remote shell and command execution.  In this case we use ssh for execution of the Subversion (open source version control system) commands.

Command svnlook returns all revisions, so I use gawk to pick only first and last for the requested branch, and then send that boundaries as a parameters to the svn log command.

<%@page contentType=”text/html” pageEncoding=”UTF-8″ import=”java.io.*,com.trilead.ssh2.*”%>
<!DOCTYPE html>
<html>
<body>
<%String ver=request.getParameter(“ver”);
      String hostname = “…”;
      String username = “…”;
      String password = “…”;
      try { Connection conn = new Connection(hostname);
            conn.connect();
            if(conn.authenticateWithPassword(username, password) == false)
               throw new IOException(“Authentication failed.”);
           Session sess = conn.openSession();
           String cmd=”svnlook history /svnroot/zis /REL/it_v2.28 | gawk ‘$2==\”/REL/it_v2.28\” {x+=1; a[x]=$1;} END {print a[1]; print a[x];}‘”;
         cmd+=” | (read line; hi=$line; read line; lo=$line; svn log
http://svnhost/it_v2.28 -r$lo:$hi -v)”;
         if(ver!=null) { cmd=cmd.replaceAll(“2.28”,ver);}
         sess.execCommand(cmd);
         InputStream stdout = new StreamGobbler(sess.getStdout());
         BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
         while(true)
           { String line = br.readLine();
             if(line == null) break;
             out.println(line+”<br>”);
           }

         sess.close();
         conn.close();
     }catch (IOException e) {e.printStackTrace(System.err);System.exit(2);}

%>   
</body>
</html>

Oglasi
Ovaj unos je objavljen u Nekategorizirano. Bookmarkirajte stalnu vezu.

Komentiraj

Popunite niže tražene podatke ili kliknite na neku od ikona za prijavu:

WordPress.com Logo

Ovaj komentar pišete koristeći vaš WordPress.com račun. Odjava / Izmijeni )

Twitter picture

Ovaj komentar pišete koristeći vaš Twitter račun. Odjava / Izmijeni )

Facebook slika

Ovaj komentar pišete koristeći vaš Facebook račun. Odjava / Izmijeni )

Google+ photo

Ovaj komentar pišete koristeći vaš Google+ račun. Odjava / Izmijeni )

Spajanje na %s