Jenkins CLI

Skip to end of metadata
Go to start of metadata

Jenkins has a built-in command line client that allows you to access Jenkins from a script or from your shell. This is convenient for automation of routine tasks, bulk updates, trouble diagnosis, and so on.

Obtaining CLI

Jenkins CLI is distributed inside jenkins.war as a jar file. See http://yourserver.com/cli for where to download the CLI jar file. In theory, the CLI jar is dependent on the version of Jenkins, but in practice, we expect to be able to retain compatibility between different versions of Jenkins.

Running CLI

The general syntax is as follows (the design is similar to tools like svn/git):

java -jar jenkins-cli.jar [-s JENKINS_URL] command [options...] [arguments...]

JENKINS_URL can be specified via the environment variable $JENKINS_URL. This environment variable is automatically set when Jenkins fork a process during builds, which allows you to use Jenkins CLI from inside the build without explicitly configuring the URL.

Getting help

The list of the available commands depends on the server you are talking to. Visit http://yourserver.com/cli or use 'help' command to list them all:

java -jar jenkins-cli.jar -s yourserver.com help [command]

Detailed description can be obtained providing command name or visiting command page in Jenkins UI.

Extending CLI

Plugins installed on Jenkins server can add custom CLI commands. See Writing CLI commands for more details.

Working with Credentials

1.419 and later

If your Jenkins requires authentication, you should set up public key authentication. Login from the web UI and go to http://yourserver.com/me/configure, then set your public keys in the designated text area. When connecting to the server, the CLI will look for ~/.ssh/identity, ~/.ssh/id_dsa, ~/.ssh/id_rsa and use those to authenticate itself against the server. Alternatively, the -i option can be used to explicitly specify the location of the private key.

See the middle of this guide for how to generate SSH key pair, if you don't have one yet.

If you have used PuttyGen to generate your keys, you will have to convert them to openssh format. Otherwise Jenkins might silently ignore your keys and you will be Authenticated as: anonymous.

To use the -i option the syntax is as follows:

java -jar jenkins-cli.jar [-s JENKINS_URL] [-i PRIVATE_KEY] command [options...] [arguments...]
For compatibility reasons, unless you use the -i option, failure to authenticate by itself does not constitute a fatal error. It will instead try to execute the command anyway, as the anonymous user.

Before 1.419

If your Jenkins requires authentication, use --username and --password or --password-file options to specify the credentials. To avoid doing this for every command, you can also use the login CLI command once (with the same credentials parameters), and after that you may use other commands without specifying credentials.
Note that not every authentication type supports these parameters for credentials. Prior to version 1.373, only authentication in Jenkins' own database was supported. As of 1.373, LDAP is also supported. If the CLI reports these are invalid parameters, file an issue for your authentication type and ask them to extend AbstractPasswordBasedSecurityRealm instead of directly from SecurityRealm to get support for these parameters.

Change History: Note that a security hole in CLI commands was fixed in version 1.371, and that CLI login did not work properly for many commands until 1.375.

Connection mechanism

Jenkins CLI clients and Jenkins server establishes the communication in the following fashion.

  1. Jenkins listens on a TCP/IP port configured under "TCP port for JNLP slave agents" in the system configuration page. This single port is used for both slaves and CLI.
  2. Jenkins advertises this port number as a special HTTP header (if disabled, this header will not be present.)
  3. CLI client will make an HTTP request to the top page of Jenkins, looking for this header.
  4. If the header is found and the TCP/IP port is identified, the client will attempt to connect to this URL.
  5. If that fails (for example, if there's a reverse proxy and Jenkins runs on a different host, or if a firewall blocks access to this TCP/IP port), or if the header is not found, it will fall back to the communication mechanism that uses two simultaenous HTTP connections.
Use 1.427 for the fallback behavior
Up until 1.426, if the server advertises a separate TCP/IP port, then a client failure to connect to this port was fatal. Since 1.427, the client is improved to fall back to HTTP-based mechanism. See issue #10611

Configuring TCP/IP port for CLI and slaves. 

You have to configure global security in order to select the port (rather than system configuration). Using a fixed port allows you to configure your firewall more easily.

Commons problems

Operation timed out

$ java -jar jenkins-cli.jar -s YOUR_SERVER_URL help
Exception in thread "main" java.net.ConnectException: Operation timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
	at java.net.Socket.connect(Socket.java:529)
	at java.net.Socket.connect(Socket.java:478)
	at java.net.Socket.<init>(Socket.java:375)
	at java.net.Socket.<init>(Socket.java:189)
	at hudson.cli.CLI.<init>(CLI.java:97)
	at hudson.cli.CLI.<init>(CLI.java:82)
	at hudson.cli.CLI._main(CLI.java:250)
	at hudson.cli.CLI.main(CLI.java:199)

Check that the JNLP port is opened if you are using a firewall on your server. You can configure its value in Jenkins configuration. By default it is set to use a random port.

java.io.EOFException

$ java -jar jenkins-cli.jar -s YOUR_SERVER_URL login
Exception in thread "main" java.io.EOFException
	at java.io.DataInputStream.readBoolean(DataInputStream.java:227)
	at hudson.cli.Connection.readBoolean(Connection.java:90)
	at hudson.cli.CLI.authenticate(CLI.java:360)
	at hudson.cli.CLI._main(CLI.java:255)
	at hudson.cli.CLI.main(CLI.java:199)

If on the server side you have such logs (perhaps with another security manager)

INFO: Accepted connection #54 from /88.171.115.235:60876
Exception in thread "Thread-3518" java.lang.UnsupportedOperationException: Not giving you the password
	at com.atlassian.crowd.integration.acegi.user.CrowdUserDetails.getPassword(CrowdUserDetails.java:52)
	at hudson.model.User.impersonate(User.java:250)
	at org.jenkinsci.main.modules.cli.auth.ssh.SshCliAuthenticator.authenticate(SshCliAuthenticator.java:44)
	at hudson.cli.CliManagerImpl$1.run(CliManagerImpl.java:99)

This issues was fixed in Jenkins 1.424

java.io.IOException / javax.net.ssl.SSLHandshakeException (SSL certificate issue)

You may face this issue if the certificate is not trusted, e.g. self-signed certificate.

bash-4.1$ java -jar jenkins-cli.jar -s https://jenkins.example.com/ help
Exception in thread "main" java.io.IOException: Failed to connect to https://jenkins.example.com/
	at hudson.cli.CLI.getCliTcpPort(CLI.java:274)
	at hudson.cli.CLI.<init>(CLI.java:134)
	at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
	at hudson.cli.CLI._main(CLI.java:469)
	at hudson.cli.CLI.main(CLI.java:384)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1682)
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:257)
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:251)
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1168)
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:609)
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:545)
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:930)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1175)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1202)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1186)
	at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:440)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
	at hudson.cli.CLI.getCliTcpPort(CLI.java:272)
	... 4 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:324)
	at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:224)
	at sun.security.validator.Validator.validate(Validator.java:235)
	at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:147)
	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:230)
	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:270)
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1147)
	... 15 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:197)
	at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:255)
	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:319)
	... 21 more

see https://issues.jenkins-ci.org/browse/JENKINS-12629 for a way to trust a self-signed certificate (rather than using -noCertificateCheck option)

JENKINS_HOST=jenkins.example.com
JENKINS_PORT=443
JENKINS_URL=https://${JENKINS_HOST}:${JENKINS_PORT}
KEYSTOREFILE=myKeystore
KEYSTOREPASS=changeme

# get the SSL certificate
openssl s_client -connect ${JENKINS_HOST}:${JENKINS_PORT} </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ${JENKINS_HOST}.cer
# create a keystore and import certificate
keytool -import -noprompt -trustcacerts -alias ${JENKINS_HOST} -file ${JENKINS_HOST}.cer -keystore ${KEYSTOREFILE} -storepass ${KEYSTOREPASS}
# verify that the certificate is listed
keytool -list -v -keystore ${KEYSTOREFILE} -storepass ${KEYSTOREPASS}
# get jenkins-cli
wget --no-check-certificate ${JENKINS_URL}/jnlpJars/jenkins-cli.jar
# test access
alias jcli="java -Djavax.net.ssl.trustStore=${KEYSTOREFILE} -Djavax.net.ssl.trustStorePassword=${KEYSTOREPASS} -jar jenkins-cli.jar -s ${JENKINS_URL,,}"
jcli help
# ... or set this in your ~/.bashrc
export JAVA_TOOL_OPTIONS="-Djavax.net.ssl.trustStore=${KEYSTOREFILE} -Djavax.net.ssl.trustStorePassword=${KEYSTOREPASS}"
java -jar jenkins-cli.jar -s ${JENKINS_URL} help
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 05, 2009

    Rémy EVEN says:

    What about protocol and port using by hudson-cli ? Thanks

    What about protocol and port using by hudson-cli ?

    Thanks

  2. May 19, 2009

    Frederic Jean says:

    Is it possible to pass credentials to hudson-cli?

    Is it possible to pass credentials to hudson-cli?

  3. Feb 04, 2010

    benson margulies says:

    Can I pass parameters to the 'build' command?

    Can I pass parameters to the 'build' command?

    1. Aug 10, 2012

      Oddity Overseer says:

      yes. Here's the usage for build: $ ssh -p 38844 -i ~/.ssh/jenkins jenkins@loca...

      yes. Here's the usage for build:

      $ ssh -p 38844 -i ~/.ssh/jenkins jenkins@localhost build
      Argument "JOB" is required
      java -jar jenkins-cli.jar build args...
      Starts a build, and optionally waits for a completion.
      Aside from general scripting use, this command can be
      used to invoke another job from within a build of one job.
      With the -s option, this command changes the exit code based on
      the outcome of the build (exit code 0 indicates a success.)
      With the -c option, a build will only run if there has been
      an SCM change
       JOB                 : Name of the job to build
       -c                  : Check for SCM changes before starting the build, and if
                             there's no change, exit without doing a build
       -p                  : Specify the build parameters in the key=value format.
       -s                  : Wait until the completion/abortion of the command
       -v                  : Prints out the console output of the build. Use with -s
       -w                  : Wait until the start of the command
       --username VAL      : User name to authenticate yourself to Jenkins
       --password VAL      : Password for authentication. Note that passing a
                             password in arguments is insecure.
       --password-file VAL : File that contains the password
      
  4. Apr 09, 2010

    Axel Heider says:

    Is there a list of commands that can be used? I did not find anything, so if the...

    Is there a list of commands that can be used? I did not find anything, so if there is something a link in the Wiki page would help.

    1. May 03, 2010

      Jes Struck says:

      use help as a command the it's self documented

      use help as a command the it's self documented

  5. May 24, 2010

    selckin - says:

    The correct HUDSON_URL is your-url + "/cli", if you go that address the example ...

    The correct HUDSON_URL is your-url + "/cli", if you go that address the example there will even lie to you (not including /cli)

    1. Sep 25, 2010

      Alexander Lehmann says:

       @Thomas: actually HUDSON_URL is http://server:8080/hudson/ (or whatever) a...

       @Thomas: actually HUDSON_URL is http://server:8080/hudson/ (or whatever) and that can be passed to the command, since it adds /cli at the end.

      (at least in 1.377 it does)

  6. Sep 25, 2010

    Alexander Lehmann says:

    I'd like to propose an edit to the section about Credentials: The parameters &#...

    I'd like to propose an edit to the section about Credentials:

    The parameters --username and --password can appear only after the command and not before.

    (I found that somewhat confusing since the login applies to the service and not to the individual command)

  7. Dec 13, 2010

    Dave Bottger says:

    FYI - The option to wait when using the "build" command is "-s" i.e. java -...

    FYI - The option to wait when using the "build" command is "-s"

    i.e. java -jar hudson-cli.jar -s http://<server>/hudson/ build --username <username> --password-file </path/to/file/containing/plain/text/password> -s -p buildparam1=<value1> -p buildparam2=<value2>

                                                                                                                                                                                                                    ^^ ---- that is the "-s" that tells the build to wait

  8. Jan 09, 2011

    Adam Zehavi says:

    Hi, I was wondering... I've jumped into Hudson, and I saw a piece of CLI like th...

    Hi, I was wondering... I've jumped into Hudson, and I saw a piece of CLI like this:

    java -jar hudson-cli.jar -s http://<server>/hudson/ build -s <Job Name> -p buildparam1=<value1> -p buildparam2=<value2> GROUP=<blah>

    and then I got that the buildparam1 and buildparam2 are the ones defined within the job, yet I need to set their value?!
    I've been told by the guys I'm working with/for that the number of parameters supplied in the cli must match exactly to the parameters defined in the web UI job editing page. Which brings me to these questions:

    Does the number of parameters matters? what if I supply an extra unused parameter? what if supply less? would it get the default value as I defined in the editor?

    Thanks in advance,
    Adam Zehavi.

  9. Jun 09, 2011

    Parag Doke says:

    Is it possible ootb to re-use the credentials with which a job was invoked ? Fo...

    Is it possible ootb to re-use the credentials with which a job was invoked ?

    For example, let's say I have 2 jobs:

    1) RunMe

    2) Target

    Within job RunMe, if I invoke ant and make a call to jenkins-cli.jar with "enable-job" and "Target" as arguments, can it re-use the credentials with which RunMe was invoked ? I ask this in context of LDAP authentication. I tried and ran into "hudson.security.AccessDeniedException2: anonymous is missing the Configure permission".

    Ant snippet:

            <java jar="jenkins-cli.jar" fork="true">
                <arg value="enable-job"/>
                <arg value="Target"/>
            </java>

  10. Jul 21, 2011

    ken yu says:

    many thanks that the CLI is very useful in my project, it will be perfect if a ...

    many thanks that the CLI is very useful in my project, it will be perfect if a more detail guide or sample provided, such as when creates a new job it will read stdin as a configuration XML file, the question is how to define the XML file, what infomation is mandatory and what format we have to follow.

    1. Mar 31, 2012

      Larry Cai says:

      try create one job inside jenkins and use command line to export the job xml via...

      try create one job inside jenkins and use command line to export the job xml via. `get-job` command

  11. Oct 06, 2011

    Marcus Pereira says:

    What is [this guide] for? Can you create this page, orstate some other link docu...

    What is [this guide] for? Can you create this page, orstate some other link documenting it, please?

  12. Feb 01, 2012

    marlene cote says:

    Is there any way to return the job number when you run the build command to kick...

    Is there any way to return the job number when you run the build command to kick off another job?

  13. Mar 31, 2012

    Larry Cai says:

    I hope it can support `get-job --all` to export all jobs, and later I can `creat...

    I hope it can support `get-job --all` to export all jobs, and later I can `create-job -all < backup.xml`.

    Currently job name must be provided for the command

  14. May 01, 2012

    Martin Andersen says:

    Is it possible to provide parameters to groovy scripts? For example, I would li...

    Is it possible to provide parameters to groovy scripts?

    For example, I would like to run: java -jar jenkins-cli.jar groovy myscript.groovy myparameter1 myparameter2

    And how would that be referenced within the groovy script (if possible)?

  15. May 21, 2012

    Zeev Tavor says:

    Hello all, When I trying to run build job from CLI with parameters to plugins I...

    Hello all,

    When I trying to run build job from CLI with parameters to plugins I 
    get the following error: 
    c:\Jenkins>java -jar jenkins-cli.jar -s %JENKINS_URL% build 
    "CCBL_Test" -p "PROJECTS=Test1,Test2" 
    CLI parameter submission is not supported for the class 
    com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParame terDefinition 
    type. Please file a bug report for this. 

    In case I use other parameter for ClearCase UCM baseline plugin, I get 
    similar error: 
    c:\Jenkins>java -jar jenkins-cli.jar -s %JENKINS_URL% build 
    "CCBL_Test" -p "ClearCase UCM baseline=TestBL_21052012" 
    CLI parameter submission is not supported for the class 
    com.michelin.cio.hudson.plugins.clearcaseucmbaseline.ClearCaseUcmBaselinePa rameterDefinition 
    type. Please file a bug report for this 

    Is it possible plugins don't support CLI parameters?? 
    What I'm doing wrong? 

    Please advice, 
    Thanks

  16. Jun 13, 2012

    Stephane Odul says:

    For some reason my main Jenkins instance is refusing the -v option when trig...

    For some reason my main Jenkins instance is refusing the -v option when triggering a build.

    Here is the output from our main server:

    $ java -jar /tmp/jenkins-cli.jar -s http://jenkins-dev/  build
    Argument "JOB" is required
    java -jar jenkins-cli.jar build args...
    Starts a build, and optionally waits for a completion.
    Aside from general scripting use, this command can be
    used to invoke another job from within a build of one job.
    With the -s option, this command changes the exit code based on
    the outcome of the build (exit code 0 indicates a success.)
    With the -c option, a build will only run if there has been
    an SCM change
     JOB                 : Name of the job to build
     -c                  : Check for SCM changes before starting the build, and if
                           there's no change, exit without doing a build
     -p                  : Specify the build parameters in the key=value format.
     -s                  : Wait until the completion/abortion of the command
     --username VAL      : User name to authenticate yourself to Jenkins
     --password VAL      : Password for authentication. Note that passing a
                           password in arguments is insecure.
     --password-file VAL : File that contains the password
    

    From my local test instance, running the same build of Jenkins but a lot less plugging:

    $ java -jar /tmp/jenkins-cli.jar -s http://localhost:8080/  build
    Argument "JOB" is required
    java -jar jenkins-cli.jar build args...
    Starts a build, and optionally waits for a completion.
    Aside from general scripting use, this command can be
    used to invoke another job from within a build of one job.
    With the -s option, this command changes the exit code based on
    the outcome of the build (exit code 0 indicates a success.)
    With the -c option, a build will only run if there has been
    an SCM change
     JOB                 : Name of the job to build
     -c                  : Check for SCM changes before starting the build, and if
                           there's no change, exit without doing a build
     -p                  : Specify the build parameters in the key=value format.
     -s                  : Wait until the completion/abortion of the command
     -v                  : Prints out the console output of the build. Use with -s
     -w                  : Wait until the start of the command
     --username VAL      : User name to authenticate yourself to Jenkins
     --password VAL      : Password for authentication. Note that passing a
                           password in arguments is insecure.
     --password-file VAL : File that contains the password
    

    Note how -v is missing on our main server, and I cannot figure out why this is happening. Is there a known plugin that would disable the use of -v?

  17. Aug 31, 2012

    James Murray says:

    Hi, I have recently upgraded to Java Version 7 Update 7 (on Windows 7) and am n...

    Hi,

    I have recently upgraded to Java Version 7 Update 7 (on Windows 7) and am now getting a permission denied error from the jenkins-cli.jar.

    I can access the URL below fine in a web browser so is not DNS/firewall/authentication.

    Any thoughts on what could be causing this?

    Thanks,

    James.

    C:\Dev\Wave\Integration\WaveKickStart\WaveKickStart\bin\Release>java -jar jenkin
    s-cli.jar -s http://lonsb03.wecomm.local:8080/ help
    Exception in thread "main" java.io.IOException: Failed to connect to http://lons
    b03.wecomm.local:8080/
            at hudson.cli.CLI.getCliTcpPort(CLI.java:227)
            at hudson.cli.CLI.<init>(CLI.java:123)
            at hudson.cli.CLI.<init>(CLI.java:107)
            at hudson.cli.CLI._main(CLI.java:395)
            at hudson.cli.CLI.main(CLI.java:330)
    Caused by: java.net.SocketException: Permission denied: connect
            at java.net.DualStackPlainSocketImpl.connect0(Native Method)
            at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
            at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
            at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
            at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
            at java.net.PlainSocketImpl.connect(Unknown Source)
            at java.net.SocksSocketImpl.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at sun.net.NetworkClient.doConnect(Unknown Source)
            at sun.net.www.http.HttpClient.openServer(Unknown Source)
            at sun.net.www.http.HttpClient.openServer(Unknown Source)
            at sun.net.www.http.HttpClient.<init>(Unknown Source)
            at sun.net.www.http.HttpClient.New(Unknown Source)
            at sun.net.www.http.HttpClient.New(Unknown Source)
            at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
    Source)
            at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
    ce)
            at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
            at hudson.cli.CLI.getCliTcpPort(CLI.java:225)
            ... 4 more
    C:\Dev\Wave\Integration\WaveKickStart\WaveKickStart\bin\Release>java -jar jenkin

    s-cli.jar -s http://lonsb03.wecomm.local:8080/ help

    Exception in thread "main" java.io.IOException: Failed to connect to http://lons

    b03.wecomm.local:8080/

            at hudson.cli.CLI.getCliTcpPort(CLI.java:227)

            at hudson.cli.CLI.<init>(CLI.java:123)

            at hudson.cli.CLI.<init>(CLI.java:107)

            at hudson.cli.CLI._main(CLI.java:395)

            at hudson.cli.CLI.main(CLI.java:330)

    Caused by: java.net.SocketException: Permission denied: connect

            at java.net.DualStackPlainSocketImpl.connect0(Native Method)

            at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)

            at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)

            at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)

            at java.net.AbstractPlainSocketImpl.connect(Unknown Source)

            at java.net.PlainSocketImpl.connect(Unknown Source)

            at java.net.SocksSocketImpl.connect(Unknown Source)

            at java.net.Socket.connect(Unknown Source)

            at java.net.Socket.connect(Unknown Source)

            at sun.net.NetworkClient.doConnect(Unknown Source)

            at sun.net.www.http.HttpClient.openServer(Unknown Source)

            at sun.net.www.http.HttpClient.openServer(Unknown Source)

            at sun.net.www.http.HttpClient.<init>(Unknown Source)

            at sun.net.www.http.HttpClient.New(Unknown Source)

            at sun.net.www.http.HttpClient.New(Unknown Source)

            at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown

    Source)

            at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour

    ce)

            at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)

            at hudson.cli.CLI.getCliTcpPort(CLI.java:225)

            ... 4 more

    1. Sep 06, 2012

      James Murray says:

      I did a bit of research and found this: http://stackoverflow.com/questions/8360...

      I did a bit of research and found this:

      http://stackoverflow.com/questions/8360913/weird-java-net-socketexception-permission-denied-connect-error-when-running-groo

      I suspect I might be hitting this after upgrading to Java 1.7.

  18. Mar 25, 2013

    Frank Merrow says:

    It would be helpful if the "groovy" command would support --classpath option...

    It would be helpful if the "groovy" command would support --classpath options.

  19. Apr 30, 2013

    Alexander Artemov says:

    java.io.EOFException is reproduced in 1.512! And for some reason not every t...

    java.io.EOFException is reproduced in 1.512! And for some reason not every time. Please fix it again :)

  20. Aug 26, 2013

    T. Houdayer says:

    This could help somebody else. Our settings on our jenkins are very strict. Our...

    This could help somebody else.

    Our settings on our jenkins are very strict. Our "Configure Global Security" page set the Anonymous login with only the "Discover Job" right. This prevent us from using the normal command line everyone use:

    # DONT WORK
    $ java -jar jenkins-cli.jar -s http://our-jenkins/ -i id_rsa who-am-i
    

    We finally found that we have to use the URL to the login page:

    # WORK :)
    $ java -jar jenkins-cli.jar -s http://our-jenkins/login?form -i id_rsa who-am-i
    

    Note that "/login" is insufficient, you have to use "/login?form".

    Isn't that weird that you told to set at least the Anonymous right to "Discover Job" for the people to be redirect automatically to the login page and that single right prevent jenkins-cli to use the base URL "http://our-jenkins/" ? Just asking.

    From the tooltip of "Discover Job": 

    This permission grants discover access to jobs. Lower than read permissions, it allows you to redirect anonymous users to the login page when they try to access a job url. Without it they would get a 404 error and wouldnt be able to discover project names.

  21. Aug 27, 2013

    Walter Kacynski says:

    Does any know how to use parameters with spaces in them such as?  ssh JENK...

    Does any know how to use parameters with spaces in them such as?

     ssh JENKINS build Restart-Job -s -v -w -r 5 -p SCRIPT_FILE=stop -p SCRIPT_ARGUMENTS='WSP12A2 WSP13A1 WSP13A2'
    READY                                                                                                                          
    END                                                                                                                            
    Too many arguments: WSP13A1.                                                                                                   
    java -jar jenkins-cli.jar build args....                                                                                     

  22. Oct 02, 2013

    Martin Krischik says:

    Interesting: Exception in thread "main" java.io.IOException: PEM is encrypte...

    Interesting:

    Exception in thread "main" java.io.IOException: PEM is encrypted, but no password was specified
     at com.trilead.ssh2.crypto.PEMDecoder.decode(PEMDecoder.java:318)
     at hudson.cli.CLI.loadKey(CLI.java:550)
     at hudson.cli.CLI.loadKey(CLI.java:526)
     at hudson.cli.CLI.tryEncryptedFile(CLI.java:578)
     at hudson.cli.CLI._main(CLI.java:434)
     at hudson.cli.CLI.main(CLI.java:384)
    

    But begs the question: How do you specify the password then? — On Windows that is – judging from the source the system tries to read the console which does not work in Window.

    Martin

    PS: I really start to hate all ssh key security. It is always so hard to set up and to create scripts for.Give me the --username --password command line options back

  23. Oct 03, 2013

    Martin Krischik says:

    Tried again, this time with ssh-agent in place. But the com.trilead Library does...

    Tried again, this time with ssh-agent in place. But the com.trilead Library does not support ssh-agent.

    To make it work I need to create an ssh-key without password. Super. Very secure. Reminds me of the old saying from mechanical engineering: “After tight comes loose”.

    Martin

  24. Jan 15

    Vishal Rekala says:

    How can i disable this page?? http://jenkinsserver/cli/ For security reasons, ...

    How can i disable this page??

    http://jenkinsserver/cli/

    For security reasons, we want to make sure no one will have access to this page and have read permissions of the jenkins services.

  25. Jan 30

    polymor physm says:

    How to set and get values from jenkins CLI session in custom plugin ? I found ou...

    How to set and get values from jenkins CLI session in custom plugin ? I found out that Stapler.getCurrentRequest() does not work for jenkins cli. Any suggestions. ??