Using Jenkins' Script Console to Download Files


* Using Jenkins Script Console to Download Files
ServerA has a file test.t want to copy to ServerB, But don't have login user on ServerB.

And ServerB running a Jenkins server, we can access.

On ServerA:
    1. goto folder of test.t
    2. execute python -m SimpleHTTPServer
       19:41 ~ $ python -m SimpleHTTPServer
       Serving HTTP on port 8000 ...

On Jenkins::
    1. execute following code in Jenkins's Script Console.
String cmd ="curl <ip_of_server_A>:8000/test.t -o test.t";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
        println line;
Then, test.t will located in Home folder of user who running the Jenkins.

   2. Surely,  any Groovy Script can execute here.

No comments:

Post a Comment