0

I tried to use curl to create job , it's done successfully. But when I use python tempfile or python jenkins API ,server return a 500 error.

```

def create_job(job_name, config_xml):
    headers = {'Content-Type': 'text/xml'}
    f = tempfile.NamedTemporaryFile()
    f.write(config_xml)
    f.flush()
    f.seek(0)
    print f.read()
    re = requests.post(jenkins_url + "createItem?name=" \
                       + job_name, auth=(user_id, password), headers=headers, data=f.read())
    if re.status_code == requests.codes.ok:
        return True
    else:
        print re.text
        return False

```

Joe
  • 52
  • 1
  • 9
  • 1
    Can you include this curl request? Also, did you look into Jenkins logs? 500 error code is an internal server error therefore there can be some useful information. My bet is either your request is somehow incorrect, or this `config_xml` is invalid. – Raoslaw Szamszur Nov 27 '18 at 11:30
  • yes I had fix that. config_xml has a blank line at first line, so it return 500. Think You – Joe Nov 29 '18 at 09:32

1 Answers1

0

Config_xml content format is not right .

Joe
  • 52
  • 1
  • 9