# Unable to create jenkins job using anisble

**URL:** <https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092>\
**Category:** Ansible Project\
**Created:** [June 13, 2023, 1:02am UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092 "2023-06-13T01:02:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 1:02am UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/1 "2023-06-13T01:02:29Z")

</div>

I am trying to create a jenkins job using ansible “community.general.jenkins\_job”, but I am getting below error. Also I used existing job config.xml

The full traceback is:  
Traceback (most recent call last):  
File “/tmp/ansible\_community.general.jenkins\_job\_payload\_jul5utxw/ansible\_community.general.jenkins\_job\_payload.zip/ansible\_collections/community/general/plugins/modules/jenkins\_job.py”, line 313, in create\_job  
File “/tmp/ansible\_community.general.jenkins\_job\_payload\_jul5utxw/ansible\_community.general.jenkins\_job\_payload.zip/ansible\_collections/community/general/plugins/modules/jenkins\_job.py”, line 245, in get\_config  
File “/tmp/ansible\_community.general.jenkins\_job\_payload\_jul5utxw/ansible\_community.general.jenkins\_job\_payload.zip/ansible\_collections/community/general/plugins/modules/jenkins\_job.py”, line 350, in job\_config\_to\_string  
File “/usr/lib64/python3.6/xml/etree/ElementTree.py”, line 1314, in XML  
parser.feed(text)  
File “”, line None  
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0  
fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“config”: “/home/teamci-deploy-user/gitrepo/jenkins/build.com/config.xml”,  
“enabled”: null,  
“name”: “axwarpsynctest”,  
“password”: null,  
“state”: “present”,  
“token”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“url”: “[https://build.com](https://build.com)”,  
“user”: “[nchitturi@domain.com](mailto:nchitturi@domain.com)”,  
“validate\_certs”: true  
}  
},  
“msg”: “Unable to create job, not well-formed (invalid token): line 1, column 0 for [https://build.com](https://build.com)”  
}

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [June 13, 2023, 1:35am UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/2 "2023-06-13T01:35:33Z")

</div>

Seems like the config.xml is not well formatted.

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [June 13, 2023, 4:20am UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/3 "2023-06-13T04:20:23Z")

</div>

#!/bin/bash

check\_xml\_syntax() {  
file\_path=$1  
if xmllint --noout “$file\_path” &\>/dev/null; then  
echo “XML syntax is valid.”  
return 0  
else  
echo “Invalid XML syntax: $(xmllint --errors “$file\_path”)”  
return 1  
fi  
}

format\_xml() {  
file\_path=$1  
xmllint --format --output “$file\_path” “$file\_path” &\>/dev/null  
echo “XML file formatted successfully.”  
}

config\_file\_path=“/home/teamci-deploy-user/gitrepo/jenkins/build.com/config.xml”

# Check XML syntax

if ! check\_xml\_syntax “$config\_file\_path”; then  
exit 1  
fi

format\_xml “$config\_file\_path”

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 6:02am UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/4 "2023-06-13T06:02:01Z")

</div>

It says that, but I did not touch the configuration.xml, I just used the conf from the existing Jenkins job.

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 6:02am UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/5 "2023-06-13T06:02:54Z")

</div>

Thankyou will try this

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 4:53pm UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/6 "2023-06-13T16:53:10Z")

</div>

I tried this but getting below error  
Unknown option --errors  
Invalid XML syntax: Usage : xmllint [options] XMLfiles …

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [June 13, 2023, 5:09pm UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/7 "2023-06-13T17:09:36Z")

</div>

Just try plain xmllint, you’re now debugging someone else’s script.

xmllint path/to/configuration.xml

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 7:06pm UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/8 "2023-06-13T19:06:17Z")

</div>

thankyou,  
I tried xmllint \>config.xml\>  
it did not throw any warning or error, still I am getting same error, also I tried to get basic config.xml and tired.no use

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 7:26pm UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/9 "2023-06-13T19:26:07Z")

</div>

it is showing error at the below point , do I need to use any other version of python?

File “/usr/lib64/python3.6/xml/etree/ElementTree.py”, line 1314, in XML  
parser.feed(text)  
File “”, line None  
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0  
fatal: [localhost]: FAILED! =\> {

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [June 13, 2023, 7:46pm UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/10 "2023-06-13T19:46:08Z")

</div>

Please use the file lookup plugin to read config xml instead of just the filename like -

config: “{{ lookup(‘file’, ‘templates/test.xml’) }}”

---

<div class="post-metadata">

**Author:** ![Narmada\_Karthika](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@Narmada\_Karthika](https://forum.ansible.com/u/Narmada_Karthika)\
**Post date:** [June 13, 2023, 10:16pm UTC](https://forum.ansible.com/t/unable-to-create-jenkins-job-using-anisble/38092/11 "2023-06-13T22:16:12Z")

</div>

Thank you Abhijeet, I tried your option, it stopped complaining about config errors  
second error what I fixed is the user which I am trying to use is not admin on jenkins, after granting access, I am able to configure the job

Thanks a lot every one.
