build_job: return queue item identifier
Since Jenkins version 1.519 (released 2013/06/17), build_job() would always return an empty string (the empty HTTP body from the POST request). Read the HTTP response's Location header and return the queue ID number. Clients can use this number to query server for the the upcoming job's status. Change-Id: I2a1ef3abb7e675e0ad37dd8eb4a377af22f27a03 Closes-Bug: #1724932
This commit is contained in:
		@@ -1175,9 +1175,17 @@ class Jenkins(object):
 | 
			
		||||
        :param name: name of job
 | 
			
		||||
        :param parameters: parameters for job, or ``None``, ``dict``
 | 
			
		||||
        :param token: Jenkins API token
 | 
			
		||||
        :returns: ``int`` queue item
 | 
			
		||||
        '''
 | 
			
		||||
        return self.jenkins_open(requests.Request(
 | 
			
		||||
        response = self.jenkins_request(requests.Request(
 | 
			
		||||
            'POST', self.build_job_url(name, parameters, token)))
 | 
			
		||||
        location = response.headers['Location']
 | 
			
		||||
        # location is a queue item, eg. "http://jenkins/queue/item/25/"
 | 
			
		||||
        if location.endswith('/'):
 | 
			
		||||
            location = location[:-1]
 | 
			
		||||
        parts = location.split('/')
 | 
			
		||||
        number = int(parts[-1])
 | 
			
		||||
        return number
 | 
			
		||||
 | 
			
		||||
    def run_script(self, script):
 | 
			
		||||
        '''Execute a groovy script on the jenkins master.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user