When running jenkins-cli unauthenticated and authentication is required, jenkins-cli will sometimes give a hudson.remoting.ChannelClosedException exception. This seems to happen on the first invocation of the client. Subsequent executions seem okay.
[root@jenkins2 groovy_scripts]# java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080 groovy /ccs/home/msg31/master.groovy ERROR: anonymous is missing the Overall/Read permission Apr 21, 2016 9:00:32 AM hudson.remoting.RemoteInvocationHandler$Unexporter run WARNING: Couldn't clean up oid=3 from null hudson.remoting.ChannelClosedException: channel is already closed at hudson.remoting.Channel.send(Channel.java:578) at hudson.remoting.RemoteInvocationHandler$PhantomReferenceImpl.cleanup(RemoteInvocationHandler.java:360) at hudson.remoting.RemoteInvocationHandler$PhantomReferenceImpl.access$700(RemoteInvocationHandler.java:319) at hudson.remoting.RemoteInvocationHandler$Unexporter.run(RemoteInvocationHandler.java:420) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110) at java.lang.Thread.run(Thread.java:745) Caused by: hudson.remoting.Channel$OrderlyShutdown at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080) at hudson.remoting.Channel$1.handle(Channel.java:501) at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60) Caused by: Command close created at at hudson.remoting.Command.<init>(Command.java:56) at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1074) at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1072) at hudson.remoting.Channel.close(Channel.java:1156) at hudson.remoting.Channel.close(Channel.java:1138) at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1079) ... 2 more
[root@jenkins2 groovy_scripts]# java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080 groovy /ccs/home/msg31/master.groovy ERROR: anonymous is missing the Overall/Read permission