sridattas
sridattas

Reputation: 509

"Server returned HTTP response code: 403" error installing Jenkins plugin

I'm seeing the below error when I try to install plugins for Jenkins.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\tech>cd C:\Program Files (x86)\Jenkins

C:\Program Files (x86)\Jenkins>java -jar jenkins-cli.jar -s http://localhost:8081/ install-plugin ant.hpi -deploy -restart

Exception in thread "main" java.io.IOException: No X-Jenkins-CLI2-Port among [null, X-Required-Permission, X-Jenkins,
X-You-Are-In-Group, X-Hudson, Content-Length, Expires, X-You-Are-Authenticated-As, X-Permission-Implied-By, Set-Cookie,
Server, X-Content-Type-Options, Date, X-Jenkins-Session, Content-Type]
        at hudson.cli.CLI.getCliTcpPort(CLI.java:290)
        at hudson.cli.CLI.<init>(CLI.java:133)
        at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
        at hudson.cli.CLI._main(CLI.java:474)
        at hudson.cli.CLI.main(CLI.java:389)
        Suppressed: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8081/cli
                at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
                at hudson.cli.FullDuplexHttpStream.<init>(FullDuplexHttpStream.java:78)
                at hudson.cli.CLI.connectViaHttp(CLI.java:163)
                at hudson.cli.CLI.<init>(CLI.java:137)
                ... 3 more
  1. I have installed Jenkins as a Windows Installer
  2. Windows service started
  3. Then I copied jenkins-cli.jar to the jenkins folder
  4. ant.hpi file is located at jenkins folder itself (I also copied to different drive and gave the absolute path during installation)
  5. Enter the command to install plugin which resulted in error as shown above

Upvotes: 4

Views: 13818

Answers (2)

Nandakumar Purohit
Nandakumar Purohit

Reputation: 81

After some trial and errors, got it working by this aliasing statement for jenkins-cli

alias jenkins-cli='java -jar /var/lib/jenkins/jenkins-cli.jar -auth admin:admin'

After this aliasing, you can use the commands like:

jenkins-cli help jenkins-cli who-am-i

and many other commands (listed by help)

In my case here, I had added SSH key for 'admin' user of Jenkins and I had changed its password to 'admin'

Upvotes: 0

Christopher Orr
Christopher Orr

Reputation: 111555

From the troubleshooting section of the CLI documentation:

Go to Manage Jenkins > Configure Global Security and choose "Fixed" or "Random" under TCP port for JNLP agents.

The CLI is disabled by default; you need to enable this TCP port in Jenkins so that CLI clients may connect.


Also, assuming that your Jenkins master has access to the internet, you can just specify the ant plugin ID on the command line to install the Ant Plugin (and its dependencies!) directly from the Jenkins Update Centre, rather than having to download and specify each of the required .hpi files.

Upvotes: 8

Related Questions