Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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
like image 398
sridattas Avatar asked Sep 13 '25 07:09

sridattas


1 Answers

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.

like image 134
Christopher Orr Avatar answered Sep 15 '25 06:09

Christopher Orr