Skip to main content

How to update job config files using the Python API?

Comments

2 comments

  • Joyce Chidiadi

    Hi,

    Thanks for the explanation for updating job config files. I've tried this method but it doesn't work for me. Can you please let me know if this method currently works for you.

     

    Thank you.

    1
  • Mihir Mehta

    I have also tried that method, doesn't work, also unable to create_job as well, keep failing.I also tried creating a requests still getting 403 errors:
    here is the code below I have tried, but keep failing:

    ```

    import requests
    auth = (user, pswd)
    #print(auth)
    crumb_data= requests.get("{0}/crumbIssuer/api/json".format(url),auth=auth,headers={'content-type': 'application/json'}, verify=False)
    sessionID = crumb_data.headers['X-Jenkins-Session']
    print(sessionID)
    print("HAL CRUMB: {}".format(crumb_data.json()['crumb']))
    job_url = "{}/{}".format(url,url_job)

    headers = {
    'Connection': 'keep-alive',
    'Cache-Control': 'no-cache',
    'Content-Type': 'application/json',
    'Content-Encoding': 'gzip',
    'Jenkins-Crumb': crumb_data.json()['crumb'],
    'X-Jenkins-Session': sessionID
    }
    pprint(headers)
    response = requests.post(job_url, headers=headers, data=params, verify=False)
    print(response.text.encode('utf8'))

    ```

    0

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.