0
votes

I'm trying to use Jenkins CLI to install a Jenkins plugin, however receiving an error.

Plugin install command:

java -jar jenkins-cli.jar -s http://<jenkins_ip>:8080/ -auth @/home/ec2-user/credentials install-plugin parameterized-trigger http://updates.jenkins-ci.org/download/plugins/sonar/2.13/sonar.hpi restart

Error:

Installing a plugin from http://updates.jenkins-ci.org/download/plugins/sonar/2.13/sonar.hpi
ERROR: Unexpected exception occurred while performing install-plugin command.
java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.jar.JarFile.<init>(JarFile.java:166)
        at java.util.jar.JarFile.<init>(JarFile.java:130)
        at hudson.cli.InstallPluginCommand.moveToFinalLocation(InstallPluginCommand.java:177)
        at hudson.cli.InstallPluginCommand.run(InstallPluginCommand.java:111)
        at hudson.cli.CLICommand.main(CLICommand.java:249)
        at hudson.cli.CLIAction$ServerSideImpl.run(CLIAction.java:277)
        at hudson.cli.CLIAction$PlainCliEndpointResponse$1.run(CLIActio

What I have tried out:

  1. Changing java version, now I have tried for both java 8 and 11.
  2. Re downloading jenkins CLI to ensure it's not corrupted
  3. Install a similar plugin from the Jenkins interface and this worked successfully.
  4. Other Jenkins CLI commands such as list-plugins work successfully.
  5. Zip is installed on the linux server on which I'm running jenkins CLI commands. Jenkins application runs on the same server.

Jenkins version: Jenkins 2.263.4

Appreciate an input on this.

Thank You

1

1 Answers

0
votes

The URL for the plugin is outdated. There's a HTTP 302 redirection on your URL, but Jenkins apparently does not follow that.

Try installing with the redirected plugin URL https://get.jenkins.io/plugins/sonar/2.13/sonar.hpi, that should work fine.