url = 'https://myjenkins/job/myjob/build'
req = urllib.request.Request(url)
auth = 'Basic ' + base64.urlsafe_b64encode('myuser:mypassword')
req.add_header('Authorization', auth)
with open('integration.xml', 'r') as f:
    file0 = f.read()
data = {'name': 'integration.xml', 'file0': file0, 'json':
    "{'parameter': [{'name': 'integration.xml', 'file': 'file0'}]}",
    'Submit': 'Build'}
req.add_data(urllib.parse.urlencode(data))
urllib.request.urlopen(req)
How to trigger authenticated Jenkins job with file parameter using standard Python library