Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-70599

installNecessaryPlugins API redirects to a non-existent page, returns 404

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • jenkins-2.375.1 and later
    • 2.393 and 2.387.2

      We use the pluginManager API to automate plugin updates on all of our Jenkins instances. This worked really well for a long time. Since a few weeks it stopped working.

      When sending a POST request to /pluginManager/installNecessaryPlugins with the plugins to be updated it gets redirected to /updates/ with status 404.

       

      I'm sending the request like this:
      curl --request POST \
      --url http://localhost:8080/pluginManager/installNecessaryPlugins \
      --header 'Authorization: Basic <redacted-token>' \
      --header 'Content-Type: application/xml' \
      --data '<jenkins><install plugin="mattermost@3.1.2"></install></jenkins>'
       
      And I get this response:
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
      <title>Error 404 Not Found</title>
      </head>
      <body><h2>HTTP ERROR 404 Not Found</h2>
      <table>
      <tr><th>URI:</th><td>/updates/</td></tr>
      <tr><th>STATUS:</th><td>404</td></tr>
      <tr><th>MESSAGE:</th><td>Not Found</td></tr>
      <tr><th>SERVLET:</th><td>Stapler</td></tr>
      </table>
      <hr/><a href="https://eclipse.org/jetty">Powered by Jetty:// 10.0.12</a><hr/>

      </body>
      </html>

      Did anything drastically change in the API? From the docs and release notes i couldn't figure out if something has changed.

       

      Looking forward to an answer on this.

       

        1. plugins.txt
          0.8 kB
        2. run-jenkins.sh
          0.9 kB
        3. update-plugin.sh
          0.6 kB
        4. update-plugin-follow-redirect.sh
          0.7 kB

          [JENKINS-70599] installNecessaryPlugins API redirects to a non-existent page, returns 404

          Marco created issue -
          Mark Waite made changes -
          Attachment New: plugins.txt [ 59979 ]
          Attachment New: run-jenkins.sh [ 59980 ]
          Attachment New: update-plugin.sh [ 59981 ]

          Mark Waite added a comment - - edited

          I can't duplicate the problem as reported. My attempt to duplicate included the following steps:

          1. Define a a set of plugins with 3 outdated plugins in plugins.txt (git plugin, git client plugin, and trilead api plugin are outdated)
          2. Download and run Jenkins 2.375.3 and that set of plugins with the script run-jenkins.sh
          3. Complete the setup wizard by installing no additional plugins and creating the user mwaite with the password mwaite
          4. Confirm in the plugin manager page that 3 plugins are outdated, the git plugin, git client plugin, and trilead api plugin
          5. Run the update-plugin.sh shell script that requests a crumb and stores a cookie then submits the call to installNecessaryPlugins requesting git plugin 5.0.0
          6. Confirm in the plugin manager page that 3 plugins are scheduled to be updated on next restart, the git plugin, git client plugin, and trilead api plugin
          7. Restart Jenkins and confirm that the 3 plugins were updated

          I used a different authentication technique than you used, but the same XML content.

          Mark Waite added a comment - - edited I can't duplicate the problem as reported. My attempt to duplicate included the following steps: Define a a set of plugins with 3 outdated plugins in plugins.txt (git plugin, git client plugin, and trilead api plugin are outdated) Download and run Jenkins 2.375.3 and that set of plugins with the script run-jenkins.sh Complete the setup wizard by installing no additional plugins and creating the user mwaite with the password mwaite Confirm in the plugin manager page that 3 plugins are outdated, the git plugin, git client plugin, and trilead api plugin Run the update-plugin.sh shell script that requests a crumb and stores a cookie then submits the call to installNecessaryPlugins requesting git plugin 5.0.0 Confirm in the plugin manager page that 3 plugins are scheduled to be updated on next restart, the git plugin, git client plugin, and trilead api plugin Restart Jenkins and confirm that the 3 plugins were updated I used a different authentication technique than you used, but the same XML content.

          Marco added a comment -

          Hi markewaite 

          Thanks for looking into this.

          I followed the steps you did, but I still get redirected to the 404 page for /updates.

          It looks like the different authentication method makes no difference in my scenario.

           

          Marco added a comment - Hi markewaite   Thanks for looking into this. I followed the steps you did, but I still get redirected to the 404 page for /updates. It looks like the different authentication method makes no difference in my scenario.  

          Mark Waite added a comment -

          You might check if you're using a reverse proxy and something has changed in the configuration of the reverse proxy. If that doesn't work, you could compare the differences in the source code between the versions that were working before and the current versions, in case there is something in those changes that might hint at a difference. I'm not sure that others will be able to help you without a way to duplicate the problem in their environment.

          Mark Waite added a comment - You might check if you're using a reverse proxy and something has changed in the configuration of the reverse proxy. If that doesn't work, you could compare the differences in the source code between the versions that were working before and the current versions, in case there is something in those changes that might hint at a difference. I'm not sure that others will be able to help you without a way to duplicate the problem in their environment.

          Marco added a comment -

          markewaite 

          I did some digging and found that the redirect for installNecessaryPlugins has been changed in this PR: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6L1596

          https://localhost:8080/updates/ does not exist thus I get a 404 status.

          The plugin still seems to get installed but this breaks my automation I have built around it. Since the call to installNecessaryPlugins returns an error my automation will not trigger a safeRestart.

          Shouldn't a request to http://localhost:8080/pluginManager/installNecessaryPlugins get redirected to http://localhost:8080/pluginManager/updates/ as mentioned here: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6R1392 ?

           

          Marco added a comment - markewaite   I did some digging and found that the redirect for installNecessaryPlugins has been changed in this PR: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6L1596 https://localhost:8080/updates/ does not exist thus I get a 404 status. The plugin still seems to get installed but this breaks my automation I have built around it. Since the call to installNecessaryPlugins returns an error my automation will not trigger a safeRestart. Shouldn't a request to http://localhost:8080/pluginManager/installNecessaryPlugins get redirected to http://localhost:8080/pluginManager/updates/ as mentioned here: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6R1392 ?  

          Apoorva added a comment -

          I'm seeing the exact same error as well after bringing up a Jenkins with version 2.375.1.

          It works fine with older version of Jenkins.

           

          We have a wrapper script in go that uses go clinet to install plugin. I've been trying to figure out a way to get this working as I need to test with around 500 plugins. And it's impossible to do this manually.

          Apoorva added a comment - I'm seeing the exact same error as well after bringing up a Jenkins with version 2.375.1. It works fine with older version of Jenkins.   We have a wrapper script in go that uses go clinet to install plugin. I've been trying to figure out a way to get this working as I need to test with around 500 plugins. And it's impossible to do this manually.

          Mark Waite added a comment - - edited

          I think you're right that it is a bug. I can see the failed redirect if I add the --location argument to my curl command. I think that hints that one workaround might be to make the HTTP POST not follow the redirect when you perform the HTTP POST.

          I need to do more investigation to understand why that was never seen during interactive use of the plugin manager.

          I can see the bug with the following steps:

          1. Define a a set of plugins with 3 outdated plugins in plugins.txt (git plugin, git client plugin, and trilead api plugin are outdated)
          2. Download and run Jenkins 2.375.3 and that set of plugins with the script run-jenkins.sh
          3. Complete the setup wizard by installing no additional plugins and creating the user mwaite with the password mwaite
          4. Confirm in the plugin manager page that 3 plugins are outdated, the git plugin, git client plugin, and trilead api plugin
          5. Run the update-plugin-follow-redirect.sh shell script that requests a crumb and stores a cookie then submits the call to installNecessaryPlugins requesting git plugin 5.0.0 with the curl option to follow redirects
          6. Confirm that the curl command reports a 404 for the redirection to http://localhost:8080/updates/ . The old redirect to http://localhost:8080/updateCenter still works, but I think that would redirect the user to a legacy page that does not have the navigation on the side bar
          7. Confirm in the plugin manager page that 3 plugins are scheduled to be updated on next restart, the git plugin, git client plugin, and trilead api plugin
          8. Restart Jenkins and confirm that the 3 plugins were updated

          I need help from others who better understand the redirects in PluginManager.java. janfaracik can you offer guidance?

          Mark Waite added a comment - - edited I think you're right that it is a bug. I can see the failed redirect if I add the --location argument to my curl command. I think that hints that one workaround might be to make the HTTP POST not follow the redirect when you perform the HTTP POST. I need to do more investigation to understand why that was never seen during interactive use of the plugin manager. I can see the bug with the following steps: Define a a set of plugins with 3 outdated plugins in plugins.txt (git plugin, git client plugin, and trilead api plugin are outdated) Download and run Jenkins 2.375.3 and that set of plugins with the script run-jenkins.sh Complete the setup wizard by installing no additional plugins and creating the user mwaite with the password mwaite Confirm in the plugin manager page that 3 plugins are outdated, the git plugin, git client plugin, and trilead api plugin Run the update-plugin-follow-redirect.sh shell script that requests a crumb and stores a cookie then submits the call to installNecessaryPlugins requesting git plugin 5.0.0 with the curl option to follow redirects Confirm that the curl command reports a 404 for the redirection to http://localhost:8080/updates/ . The old redirect to http://localhost:8080/updateCenter still works, but I think that would redirect the user to a legacy page that does not have the navigation on the side bar Confirm in the plugin manager page that 3 plugins are scheduled to be updated on next restart, the git plugin, git client plugin, and trilead api plugin Restart Jenkins and confirm that the 3 plugins were updated I need help from others who better understand the redirects in PluginManager.java. janfaracik can you offer guidance?
          Mark Waite made changes -
          Attachment New: update-plugin-follow-redirect.sh [ 59983 ]
          Mark Waite made changes -
          Labels New: regression

            markewaite Mark Waite
            marcodl Marco
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: