I have a Jenkins job set up with the name Test2 which I can build from Jenkins web interface. Now I want to trigger that build using JenkinsAPI. I have only been able to find example code to do other things but the API Documentation mentions the Build class. So I thought I would try to instantiate it and then wait for it to complete (hoping that would also trigger the actual build) but I am getting rather cryptic errors much earlier than that. What am I doing wrong?
import jenkinsapi
b = jenkinsapi.build.Build("http://localhost:8080", 1, "test2")
b.block_until_complete()
Gives me:
Traceback (most recent call last):
File "/Users/jonathan/Genetta/Eclipse_Django_workspace/FOO/foo/TriggerBuild.py", line 2, in <module>
b = jenkinsapi.build.Build("http://localhost:8080", 1, "test2")
File "/Users/jonathan/anaconda/lib/python2.7/site-packages/jenkinsapi/build.py", line 58, in __init__
JenkinsBase.__init__(self, url)
File "/Users/jonathan/anaconda/lib/python2.7/site-packages/jenkinsapi/jenkinsbase.py", line 35, in __init__
self.poll()
File "/Users/jonathan/anaconda/lib/python2.7/site-packages/jenkinsapi/jenkinsbase.py", line 59, in poll
data = self._poll(tree=tree)
File "/Users/jonathan/anaconda/lib/python2.7/site-packages/jenkinsapi/build.py", line 65, in _poll
return self.get_data(url, params={'depth': self.depth}, tree=tree)
File "/Users/jonathan/anaconda/lib/python2.7/site-packages/jenkinsapi/jenkinsbase.py", line 72, in get_data
requester = self.get_jenkins_obj().requester
File "/Users/jonathan/anaconda/lib/python2.7/site-packages/jenkinsapi/build.py", line 371, in get_jenkins_obj
return self.job.get_jenkins_obj()
AttributeError: 'str' object has no attribute 'get_jenkins_obj'