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

405 Method Not Allowed with Rundeck plugin

    Details

    • Similar Issues:

      Description

      The Rundeck plugin is configured with user/pass and a token under Configure System. The test connection works and the api user has access to all Rundeck jobs.

      In the Project under Post Build, I have configured Rundeck to the run the job with Jenkins variables for $BUILD_NUMBER and $JOB_NAME. The call to Rundeck fails with this:

      Notifying Rundeck...
      Error while talking to Rundeck's API at http://10.162.0.10:4440 : Invalid HTTP response 'HTTP/1.1 405 Method Not Allowed' for http://10.162.0.10:4440/api/17/job/1a5f402e-eb4b-4fd3-8528-73200e19c0ea/run?argString=-BuildNumber+19+-Client+clientname
      Build step 'Rundeck' marked build as failure

      Using curl from the same server, the API with the token works perfectly.

      curl -H "X-RunDeck-Auth-Token: ka93qMLHn4RKR0csQEp8GEbhLnotreal" --data-urlencode "argString=-BuildNumber 20 -Client clientname" http://10.162.0.10:4440/api/17/job/1a5f402e-eb4b-4fd3-8528-73200e19c0ea/run
      

      It looks like the Rundeck plugin is not using the token or is going a GET instead of a POST.

        Attachments

          Activity

          Hide
          htbu Havetobe Unknown added a comment - - edited

          Hi,

          I'm facing the same issue here. I'm using Jenkins v2.19.2 and Rundeck Plugin v3.5.4
          I can confirm that the plugin uses a GET instead of a POST and that's why it's failing hence the 405 error. The token is correctly used though. As stated in Rundeck API documentation, GET method is no longer supported to trigger a job run since API version 14 (version 18 is the current API version). POST method is now required:

          /api/14/job/[ID]/run action GET is no longer allowed (v14+), POST is required. For POST, this endpoint is now equivalent to /api/14/job/[ID]/executions. JSON request content is now supported.

          I'm surprised that this bug is only tagged as "minor" since the plugin simply does not work with recent versions of Rundeck. Workarounds using curl induce a significant amount of work to not only trigger a job but also follow job executions (polling regularly, etc...)

          Any feedback on this issue ?

          Regards,

          Show
          htbu Havetobe Unknown added a comment - - edited Hi, I'm facing the same issue here. I'm using Jenkins v2.19.2 and Rundeck Plugin v3.5.4 I can confirm that the plugin uses a GET instead of a POST and that's why it's failing hence the 405 error. The token is correctly used though. As stated in Rundeck API documentation, GET method is no longer supported to trigger a job run since API version 14 (version 18 is the current API version). POST method is now required: /api/14/job/ [ID] /run action GET is no longer allowed (v14+), POST is required. For POST, this endpoint is now equivalent to /api/14/job/ [ID] /executions. JSON request content is now supported. I'm surprised that this bug is only tagged as "minor" since the plugin simply does not work with recent versions of Rundeck. Workarounds using curl induce a significant amount of work to not only trigger a job but also follow job executions (polling regularly, etc...) Any feedback on this issue ? Regards,
          Hide
          htbu Havetobe Unknown added a comment - - edited

          I dug deeper into the plugin code and I think I found the culprit.

          The plugin is using the following class to run a job: org.rundeck.api.RunJobBuilder. This class is part of this library: https://github.com/rundeck/rundeck-api-java-client (forked from https://github.com/vbehar/rundeck-api-java-client)

          It seems that it has not been updated for recent API versions. The latest release is 13.1. On my installation the jar file is rundeck-api-java-client-12.0.jar which should mean that it supports API version 12 of Rundeck which is quite old. In years, the Rundeck API has evolved.

          This is kinda weird because the jenkins plugin seems to be actively maintained while it's using a (very) old class.

          As a workaround, you can force the API version in Jenkins and set it to 12. this should work (at least for running jobs).

          Regards,

          Show
          htbu Havetobe Unknown added a comment - - edited I dug deeper into the plugin code and I think I found the culprit. The plugin is using the following class to run a job: org.rundeck.api.RunJobBuilder. This class is part of this library: https://github.com/rundeck/rundeck-api-java-client (forked from https://github.com/vbehar/rundeck-api-java-client ) It seems that it has not been updated for recent API versions. The latest release is 13.1. On my installation the jar file is rundeck-api-java-client-12.0.jar which should mean that it supports API version 12 of Rundeck which is quite old. In years, the Rundeck API has evolved. This is kinda weird because the jenkins plugin seems to be actively maintained while it's using a (very) old class. As a workaround, you can force the API version in Jenkins and set it to 12. this should work (at least for running jobs). Regards,
          Hide
          pfleetwood Paul Fleetwood added a comment -

          Thanks for the input. I have a test environment set up that I can make these changes and test them out. In the plugin configuration for Rundeck in Jenkins, I have changed the API version from 17 to 12 to match the version in the jar file.

          Show
          pfleetwood Paul Fleetwood added a comment - Thanks for the input. I have a test environment set up that I can make these changes and test them out. In the plugin configuration for Rundeck in Jenkins, I have changed the API version from 17 to 12 to match the version in the jar file.
          Hide
          htbu Havetobe Unknown added a comment -

          You're welcome. Glad it helped

          Show
          htbu Havetobe Unknown added a comment - You're welcome. Glad it helped
          Hide
          pfleetwood Paul Fleetwood added a comment -

          I have verified that changing the API version resolved this issue.

          Show
          pfleetwood Paul Fleetwood added a comment - I have verified that changing the API version resolved this issue.

            People

            • Assignee:
              vbehar Vincent Behar
              Reporter:
              pfleetwood Paul Fleetwood
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: