3

all

I apologize if this has been asked before but I cannot find a suitable post anywhere. I am trying to build a job in my Jenkins instance using the Jenkins cli with jankins-cli.jar.

I am able to display the help information using:

java -jar jenkins-cli.jar -s http://jenkins.<company>.com/hudson help

I am also able to login:

java -jar jenkins-cli.jar -s http://jenkins.<comapny>.com/hudson \
    login --username <username>

However, for some reason I cannot build a job in my jenkins instance using the Jenkins cli. It always results in a java.lang.NullPoiinterException. Has anyone else had trouble with this?

thanks in advance!

java -jar jenkins-cli.jar -s http://jenkins.<company>.com:8080/hudson build <job>
java.lang.NullPointerException
at hudson.util.CaseInsensitiveComparator.compare(CaseInsensitiveComparator.java:40)
at hudson.util.CaseInsensitiveComparator.compare(CaseInsensitiveComparator.java:34)
at java.util.TreeMap.getEntryUsingComparator(TreeMap.java:351)
at java.util.TreeMap.getEntry(TreeMap.java:322)
at java.util.TreeMap.get(TreeMap.java:255)
at hudson.util.CopyOnWriteMap.get(CopyOnWriteMap.java:89)
at jenkins.model.Jenkins.getItem(Jenkins.java:1884)
at hudson.model.AbstractProject.findNearest(AbstractProject.java:1956)
at hudson.cli.handlers.AbstractProjectOptionHandler.parseArguments(AbstractProjectOptionHandler.java:54)
at org.kohsuke.args4j.CmdLineParser.parseArgument(CmdLineParser.java:435)
at hudson.cli.CLICommand.main(CLICommand.java:177)
at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:255)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:215)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:287)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
cpow
  • 205
  • 1
  • 4
  • 7
  • Have you verified that you aren't missing any command-line arguments? If you have, you may have encountered a bug with the Jenkins CLI. – Bernard Aug 19 '11 at 15:02

3 Answers3

0

I ran into the same Problem and could resolve it with following steps:

  • update the server and client jar files to the latest version
  • switch the authentication mode from username/password to public key authentication as described in the Jenkins wiki

After that, starting a build with java -jar jenkins-cli.jar -i keyfile -s http://jenkins.<company>.com:8080/hudson build <job> worked without any exceptions.

Michael Osl
  • 2,720
  • 1
  • 21
  • 36
0

I am not sure if You got the correct answer. This should work:

java -jar jenkins-cli.jar -s <url of the CI server> build <job name> --username <username> --password <password>

For example, if the CI server is "http://myserver.com:8080/" , job to build is "My_App_Build" , username is "myusername" , password is "mypassword" then,

java -jar jenkins-cli.jar -s http://myserver.com:8080 build My_App_Build --username myusername --password mypassword 

Note: You find errors like "No such command: --username" if the order of the parameters is not correct.

codeviper
  • 78
  • 10
0

I am not familiar with the job you are using but I know you can start jobs with the jenkins api located here

https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API

This is assuming that you have a job up and running.

Mahdi Yusuf
  • 19,931
  • 26
  • 72
  • 101