Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41201

Exception with Creating Jenkins job with Customized Template using python-jenkins API

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • python-plugin
    • None

      Exception with Creating Jenkins job with Customized Template using python-jenkins API
      --------------------------------------------------------------------------------------------------------------
      Python Code for to create jenkins Job
      -----------------------------------------------
      import jenkins

      server = jenkins.Jenkins('http://<jenkins-ip>:8080', username='admin', password='admin',timeout=1000)
      job = server.create_job(name="HelloWorld", config_xml='Template.xml')
      print( job)

      --------------------------------------------
      Exception
      -------------------------------------------
      C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\python.exe "D:/MyWorkspace/Python Workspace/HelloWorld/Test.py"
      Traceback (most recent call last):
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins_init_.py", line 431, in jenkins_open
      response = urlopen(req, timeout=self.timeout).read()
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 223, in urlopen
      return opener.open(url, data, timeout)
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 532, in open
      response = meth(req, response)
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 642, in http_response
      'http', request, response, code, msg, hdrs)
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 570, in error
      return self._call_chain(*args)
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 504, in _call_chain
      result = func(*args)
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 650, in http_error_default
      raise HTTPError(req.full_url, code, msg, hdrs, fp)
      urllib.error.HTTPError: HTTP Error 500: Server Error

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "D:/MyWorkspace/Python Workspace/HelloWorld/Test.py", line 4, in <module>
      job = server.create_job(name="HelloWorld", config_xml='Template.xml')
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins_init_.py", line 992, in create_job
      config_xml.encode('utf-8'), DEFAULT_HEADERS))
      File "C:\Users\SRI_14\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins_init_.py", line 448, in jenkins_open
      e.code, e.msg)
      jenkins.JenkinsException: Error in request. Possibly authentication failed [500]: Server Error

      Process finished with exit code 1

            jhasse Jan Niklas Hasse
            jbanimineni JayaBabu Animineni
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: