我试图通过执行groovy命令在Jenkins URL(https://jenkins.abc.com/cid/)中创建全局变量。下面是我的命令。
java -jar C:\ Temp \ jenkins-cli.jar -s“ https://jenkins.abc.com/cid/” -auth abc:def -remoing groovy C:\ Temp \ ATS \ scripts \ createGlobalVariable.groovy“ IP_VAR_Name”“ 10.19 .143.32”-用户名abc-密码def
我看到以下错误
May 14, 2019 12:53:38 PM hudson.cli.CLI connectViaCliPort
WARNING: -auth ignored when using JNLP agent port
May 14, 2019 12:53:46 PM hudson.remoting.SynchronousCommandTransport$ReaderThread run
INFO: I/O error in channel Chunked connection to https://jenkins.abc.com/cid/
java.io.IOException: Unexpected termination of the channel
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:77)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:49)
at hudson.remoting.Command.readFrom(Command.java:140)
at hudson.remoting.Command.readFrom(Command.java:126)
at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:36)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:63)
hudson.remoting.RemotingSystemException: hudson.remoting.ChannelClosedException: Channel "hudson.remoting.Channel@127982:Chunked connection to https://jenkins.abc.com/cid/": channel is already closed
at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:299)
at hudson.remoting.$Proxy1.waitForProperty(Unknown Source)
at hudson.remoting.Channel.waitForRemoteProperty(Channel.java:1582)
at hudson.cli.CLI.<init>(CLI.java:151)
at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:82)
at hudson.cli.CLI._main(CLI.java:631)
at hudson.cli.CLI.main(CLI.java:427)
Caused by: hudson.remoting.ChannelClosedException: Channel "hudson.remoting.Channel@127982:Chunked connection to https://jenkins.abc.com/cid/": channel is already closed
at hudson.remoting.Request.checkIfCanBeExecutedOnChannel(Request.java:129)
at hudson.remoting.UserRequest.checkIfCanBeExecutedOnChannel(UserRequest.java:114)
at hudson.remoting.Request.call(Request.java:148)
at hudson.remoting.Channel.call(Channel.java:956)
at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:283)
... 6 more
Caused by: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:77)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:49)
at hudson.remoting.Command.readFrom(Command.java:140)
at hudson.remoting.Command.readFrom(Command.java:126)
at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:36)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:63)
Groovy脚本是:
import hudson.slaves.EnvironmentVariablesNodeProperty
import jenkins.model.Jenkins
//Creates a global variable based on the values passed
instance = Jenkins.getInstance()
globalNodeProperties = instance.getGlobalNodeProperties()
envVarsNodePropertyList = globalNodeProperties.getAll(EnvironmentVariablesNodeProperty.class)
newEnvVarsNodeProperty = null
envVars = null
if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) {
newEnvVarsNodeProperty = new EnvironmentVariablesNodeProperty();
globalNodeProperties.add(newEnvVarsNodeProperty)
envVars = newEnvVarsNodeProperty.getEnvVars()
} else {
envVars = envVarsNodePropertyList.get(0).getEnvVars()
}
envVars.put(args[0], args[1])
instance.save()
不确定为什么会出现此错误。
任何想法!