Make canceling a queue item a POST request.

Needed by Jenkins 1.502.

(Also don't print the results of error messages so they don't
clutter stdout, but leave them there as a debug option
comments because they are very handy when debugging
Jenkins API issues.)

Change-Id: I2e1dcc1ac2344b1eb9f66292b6fd30900cb45e6d
Reviewed-on: https://review.openstack.org/22579
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/zuul/launcher/jenkins.py b/zuul/launcher/jenkins.py
index 0a79e82..1e58bce 100644
--- a/zuul/launcher/jenkins.py
+++ b/zuul/launcher/jenkins.py
@@ -133,6 +133,7 @@
 CANCEL_QUEUE = 'queue/item/%(number)s/cancelQueue'
 BUILD_INFO = 'job/%(name)s/%(number)s/api/json?depth=0'
 BUILD_DESCRIPTION = 'job/%(name)s/%(number)s/submitDescription'
+DEBUG = False
 
 
 class ExtendedJenkins(jenkins.Jenkins):
@@ -145,8 +146,9 @@
                 req.add_header('Authorization', self.auth)
             return urllib2.urlopen(req).read()
         except urllib2.HTTPError, e:
-            print e.msg
-            print e.fp.read()
+            if DEBUG:
+                print e.msg
+                print e.fp.read()
             raise
 
     def stop_build(self, name, number):
@@ -171,6 +173,7 @@
         # Jenkins returns a 302 from this URL, unless Referer is not set,
         # then you get a 404.
         request = urllib2.Request(self.server + CANCEL_QUEUE % locals(),
+                                  urllib.urlencode({}),
                                   headers={'Referer': self.server})
         self.jenkins_open(request)