Reputation: 85
I'm having some difficulties implementing the jenkins api with my python script. For example trying to add disable_job. I have my connection to jenkins working and can build jobs but disabling I can't
def disable_job(server, project):
try:
job_exists = server.get_job_name(project) # check to see if job exists
if job_exists == None:
print 'Error: Project (job) %s does not exist.\n\n' % project
ret = None
else:
server.disable_job(project)
msg = ('Disabled project (job) %s\n' % project)
except:
emsg = ('Error: Something went wrong building project (job) %s on '
'Jenkins.\n\n' % project)
print emsg
return disable_job
Upvotes: 0
Views: 1316
Reputation: 1895
import jenkins
server = jenkins.Jenkins('http://localhost:8080', username='', password='')
server.disable_job('job_name')
Upvotes: 1