title: How to trigger authenticated Jenkins job with file parameter using standard Python library
body: <p>We are currently triggering Jenkins jobs from a Python script with the help of PycURL. We would like, however, to get rid of the PycURL dependency, but have had little success so far. What makes our scenario more complicated is that we need to post a file as a parameter. Our current PycURL logic for posting the request looks as follows:</p>
  
  <pre><code>url = "https://myjenkins/job/myjob/build"
  with contextlib.closing(pycurl.Curl()) as curl:
      curl.setopt(pycurl.URL, url)
      curl.setopt(pycurl.USERPWD, "myuser:mypassword")
      curl.setopt(pycurl.SSL_VERIFYPEER, False)
      curl.setopt(pycurl.SSL_VERIFYHOST, False)
      curl.setopt(pycurl.FAILONERROR, True)
      data = [
              ("name", "integration.xml"),
              ("file0", (pycurl.FORM_FILE, "integration.xml")),
              ("json", "{'parameter': [{'name': 'integration.xml', 'file': 'file0'}]}"),
              ("Submit", "Build"),
              ]
      curl.setopt(pycurl.HTTPPOST, data)
      try:
          curl.perform()
      except pycurl.error, err:
          raise JenkinsTriggerError(curl.errstr())
  </code></pre>
  
  <p>How can we replace this with facilities from the standard Python library?</p>
  
  <p>We've tried before, but had to give up as we could not see how to upload files successfully, as you can see from <a href="https://stackoverflow.com/questions/7078561/posting-file-to-jenkins-fails=">my question on that issue</a>.</p>