cancel_queue() does not work, must use POST not GET

Bug #1246466 reported by Kevin L. Mitchell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python Jenkins
Fix Released
Undecided
Khai Do

Bug Description

The Jenkins.cancel_queue() method does not actually cancel a queued item. An investigation revealed that Jenkins (v1.529) wants a POST rather than a GET, when accessing 'queue/item/%(number)s/cancelQueue'.

Revision history for this message
Antoine "hashar" Musso (hashar) wrote :

Seems similar to #1177831 which states build_job with parameters fails since POST is not used.

See patch https://review.openstack.org/#/c/122462/1/jenkins/__init__.py which might well solve both bugs.

summary: - cancel_queue() does not work
+ cancel_queue() does not work, must use POST not GET
Revision history for this message
Khai Do (zaro0508) wrote :

Wonder if this is still a problem. I've stated in #1177831 that I don't believe it's a bug.

Changed in python-jenkins:
assignee: nobody → Khai Do (zaro0508)
Revision history for this message
Kevin L. Mitchell (klmitch) wrote :

I honestly don't know. We were using an older version of Jenkins at the time, and it's possible that they've changed something in Jenkins that would work around the issue. I'm afraid I don't have any time to look into it today, but here's the code I overrode with:

    def cancel_queue(self, number):
        """
        Cancel a queued build. The underlying method has a bug that
        renders it non-functional (it tries to do a GET request, when
        Jenkins wants a POST). This corrects the error by passing
        ``data`` to the urllib2.Request constructor.

        :param number: The queue ID number to cancel.
        """

        req = urllib2.Request(self.server + jenkins.CANCEL_QUEUE %
                              {'number': number}, data='',
                              headers={'Referer': self.server})
        self.jenkins_open(req)

In any case, the above *does* work, and was necessary because, in my experimentation at the time, I could not get a queued job to be canceled.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-jenkins (master)

Fix proposed to branch: master
Review: https://review.openstack.org/138964

Changed in python-jenkins:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-jenkins (master)

Reviewed: https://review.openstack.org/138964
Committed: https://git.openstack.org/cgit/stackforge/python-jenkins/commit/?id=5d52721264ed2e6aec466d8d1faff96e1962a501
Submitter: Jenkins
Branch: master

commit 5d52721264ed2e6aec466d8d1faff96e1962a501
Author: Khai Do <email address hidden>
Date: Wed Dec 3 22:36:20 2014 -0800

    Fix cancel_queue() method

    The cancel_queue() method needed updating because the jenkins URL
    for it has changed and the request requires a POST to work.

    Closes-Bug: #1246466
    Change-Id: I89fcee3715c67a989a08ca75c0232c4fd87375c0

Changed in python-jenkins:
status: In Progress → Fix Committed
Khai Do (zaro0508)
Changed in python-jenkins:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.