Hey John, I was not aware of the Managed Script plugin, but it worked perfectly and saved me a lot of time. Thanks!
~Ravid On Monday, February 24, 2014 5:13:14 AM UTC-5, John Vacz wrote: > > Am 22.02.2014 06:33, schrieb Ravid Te: > > Hey Everyone, > > I am new to plugin creation, and have a need to create a plugin that > generates a specific file based on user-input to a remote node containing > large strings of data. > > > *I am aware of the current "Execute Shell" build step option and "Execute > remote commands via SSH" plugin, but do not want users to have to input > this large string of data themselves into the job config shell execute text > field.* > > https://wiki.jenkins-ci.org/display/JENKINS/Managed+Script+Plugin > https://wiki.jenkins-ci.org/display/JENKINS/SharedObjects+Plugin > > > For now, I would like to create a plugin that can execute shell commands > on a remote node, once I have this, I should be able to figure out the rest > myself. > > I found this code snippet (below) which works fine for executing simple > shell commands on local jenkins system. > What I want to do is modify this code snippet to also work when the job is > configured to execute on a remote node. > When I configured the job to execute on a remote node, I received the > following error (below below) > > If executing the commands on the remote node is too hard, is there a way > to auto-input that large string of data into the execute shell text box in > the jenkins job configuration, as this would work too? > > Can anyone assist? > > Thanks very much in advance, > ~Ravid > > > [CODE SNIPPET] > > List<Cause> buildStepCause = new ArrayList(); > buildStepCause.add(new Cause() { > public String getShortDescription() { > return "Build Step started by Hello Builder"; > } > }); > listener.started(buildStepCause); > > ArgumentListBuilder args = new ArgumentListBuilder(); > if (launcher.isUnix()) { > args.add("/bin/ls"); > args.add("-la"); > } else { > args.add("dir"); //Windows > } > String homeDir = System.getProperty("user.home"); > args.add(homeDir); > try { > int r; > r = launcher.launch().cmds(args).stdout(listener).join(); > if (r != 0) { > listener.finished(Result.FAILURE); > return false; > } > } catch (IOException ioe) { > ioe.printStackTrace(listener.fatalError("Execution" + args + "failed")); > listener.finished(Result.FAILURE); > return false; > } catch (InterruptedException ie) { > ie.printStackTrace(listener.fatalError("Execution" + args + "failed")); > listener.finished(Result.FAILURE); > return false; > } > > listener.finished(Result.SUCCESS); > > > > [ERROR LOG] > > Building remotely on LocalVM <http://localhost:8080/jenkins/computer/LocalVM> > in workspace /opt/jenkins/workspace/Test > Build Step started by Hello Builder > FATAL: Execution/bin/ls -la /Users/vid401tfailedjava.io.IOException > <http://stacktrace.jenkins-ci.org/search?query=java.io.IOException>: Remote > call on LocalVM failed > at hudson.remoting.Channel.call(Channel.java:723) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.remoting.Channel.call&entity=method> > at hudson.Launcher$RemoteLauncher.launch(Launcher.java:862) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.Launcher$RemoteLauncher.launch&entity=method> > at hudson.Launcher$ProcStarter.start(Launcher.java:353) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.Launcher$ProcStarter.start&entity=method> > at hudson.Launcher$ProcStarter.join(Launcher.java:360) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.Launcher$ProcStarter.join&entity=method> > at > com.owmessaging.testplugin.HelloWorldBuilder.perform(HelloWorldBuilder.java:90) > > <http://stacktrace.jenkins-ci.org/search/?query=com.owmessaging.testplugin.HelloWorldBuilder.perform&entity=method> > at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.tasks.BuildStepMonitor$1.perform&entity=method> > at > hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:780) > > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.perform&entity=method> > at hudson.model.Build$BuildExecution.build(Build.java:199) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Build$BuildExecution.build&entity=method> > at hudson.model.Build$BuildExecution.doRun(Build.java:160) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Build$BuildExecution.doRun&entity=method> > at > hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:565) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.run&entity=method> > at hudson.model.Run.execute(Run.java:1592) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Run.execute&entity=method> > at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.FreeStyleBuild.run&entity=method> > at hudson.model.ResourceController.execute(ResourceController.java:88) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.ResourceController.execute&entity=method> > at hudson.model.Executor.run(Executor.java:237) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Executor.run&entity=method> > Caused by: java.lang.NoClassDefFoundError > <http://stacktrace.jenkins-ci.org/search?query=java.lang.NoClassDefFoundError>: > javax/servlet/ServletException > at hudson.Launcher$LocalLauncher.<init>(Launcher.java:755) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.Launcher$LocalLauncher.%3Cinit%3E&entity=method> > at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:991) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.Launcher$RemoteLaunchCallable.call&entity=method> > at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:965) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.Launcher$RemoteLaunchCallable.call&entity=method> > at hudson.remoting.UserRequest.perform(UserRequest.java:118) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.remoting.UserRequest.perform&entity=method> > at hudson.remoting.UserRequest.perform(UserRequest.java:48) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.remoting.UserRequest.perform&entity=method> > at hudson.remoting.Request$2.run(Request.java:326) > <http://stacktrace.jenkins-ci.org/search/?query=hudson.remoting.Request$2.run&entity=method> > at > hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) > > <http://stacktrace.jenkins-ci.org/search/?query=hudson.remoting.InterceptingExecutorService$1.call&entity=method> > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) > <http://stacktrace.jenkins-ci.org/search/?query=java.util.concurrent.FutureTask$Sync.innerRun&entity=method> > at java.util.concurrent.FutureTask.run(FutureTask.java:166) > <http://stacktrace.jenkins-ci.org/search/?query=java.util.concurrent.FutureTask.run&entity=method> > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) > > <http://stacktrace.jenkins-ci.org/search/?query=java.util.concurrent.ThreadPoolExecutor.runWorker&entity=method> > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > > <http://stacktrace.jenkins-ci.org/search/?query=java.util.concurrent.ThreadPoolExecutor$Worker.run&entity=method> > at java.lang.Thread.run(Thread.java:679) > <http://stacktrace.jenkins-ci.org/search/?query=java.lang.Thread.run&entity=method> > Caused by: java.lang.ClassNotFoundException > <http://stacktrace.jenkins-ci.org/search?query=java.lang.ClassNotFoundException>: > javax.servlet.ServletException > at > hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch(RemoteClassLoader.java:684) > > <http://stacktrace.jenkins-ci.org/search/?query=hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch&entity=method> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at > hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299) > at hudson.remoting.Request$2.run(Request.java:326) > at > hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) > at java.util.concurrent.FutureTask.run(FutureTask.java:262) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > at java.lang.Thread.run(Thread.java:744) > > > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
