Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload node configs with an xml content type #793

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mrrsm
Copy link

@mrrsm mrrsm commented Sep 22, 2020

Jenkins is throwing an error when the content type is not xml when uploading a node config.

@fun4jimmy
Copy link

Is there any chance this could get merged? Without this, all calls to jenkinsapi.Node.set_config_element fail with an internal error, return code 500.

Tested with Jenkins 2.277.4 and jenkinsapi 0.3.11.

@Amor122
Copy link

Amor122 commented Jun 18, 2023

Actually, when I use the basic api of jenkins( POST /computer/test4/config.xml) to update my node
config or job config ,it alerts me to add Host and Content-Length in the request headers .My jenkins verison is 2.361.4,and jenkinsapi is 0.3.13.So I think it may be a long time for users to have truble on updating their config by Jenkinsapi.

I have used Requests to avoid this defect, the program segment is wrote as follows:
`python
old_config = """

test5

/data
5
NORMAL


127.0.0.1
10009
0f4ad930-938b-4440-9d0d-14aae7951b61
-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dnative.encoding=UTF-8
60
10
15

true

test

""" new_config = old_config.replace('2', '3') raw_data = new_config.encode('utf-8') content_length = len(raw_data) host = '127.0.0.1' headers = { 'Content-Length': str(content_length), 'Host': host } response = requests.post('http://127.0.0.1:8080/computer/test5/config.xml', auth=auth, data=raw_data, headers=headers) ` I think we can fix this defect by modifying node.py on line 347 with default headers.

@mghesh-yseop
Copy link

Can someone look into this ? I tried to run upload_config with the same data received from get_config(), and it fails.
But this code calling post_xml_and_confirm_status works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants