Reputation: 145
I am very new to Jenkins and am trying to create a build job using the python API. I am using the following code that I found in the docs: https://python-jenkins.readthedocs.io/en/latest/examples.html#example-3-working-with-jenkins-jobs
But I am struggling to get pass this line of code
server.create_job(job_name, Jenkins.EMPTY_CONFIG_XML)
It is giving me an error:
AttributeError: type object 'Jenkins' has no attribute 'EMPTY_CONFIG_XML'
Am I supposed to be specifying a file path to the config.xml
?
I am just a bit confused on how the server creates the job using EMPTY_CONFIG_XML
Any help would be appreciated.
Upvotes: 2
Views: 9617
Reputation: 1324248
Check first from where you are importing your jenkins
module:
import jenkins
print jenkins.__file__
Check also if the connection is working (from the first part of Get version of Jenkins)
import jenkins
server = jenkins.Jenkins('http://localhost:8080', username='myuser', password='mypassword')
user = server.get_whoami()
version = server.get_version()
print('Hello %s from Jenkins %s' % (user['fullName'], version))
You have a similar error pending in this issue.
The string "EMPTY_FOLDER_XML
" only appears in in doc/source/examples.rst
so it is possible it is an "example" value.
The tests/jobs/test_create.py
uses
self.j.create_job(u'Test Job', self.config_xml)
with tests/jobs/base.py
defining config_xml as:
config_xml = """
<matrix-project>
<actions/>
<description>Foo</description>
</matrix-project>"""
So you can use a similar approach in order to define your own empty or minimal config.xml
.
The OP J. H points out in the comments to the simple fix:
Simply just had to install
python-jenkins
.
Upvotes: 1