79507112

Date: 2025-03-13 16:50:44
Score: 1
Natty:
Report link

Your code looks fine, I literally just did this, and replaced password with the API key, ensured the user name is my Jenkins User ID and it worked.

One thing that did stop me before replacing my password with the API key was that the URL needed to be https, perhaps that's why the connection was refused per your traceback?

server = jenkins.Jenkins('https://localhost:8080', username='jenkinsuserid', password='jenkinsapiktoken')
user = server.get_whoami()
version = server.get_version()
print('Hello %s from Jenkins %s' % (user['fullName'], version))
Reasons:
  • Whitelisted phrase (-1): it worked
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Wil