"HTTP Error 414: Request-URI Too Long" while submitting a build

Bug #1687551 reported by Gan Huang
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Python Jenkins
In Progress
Undecided
liuxun

Bug Description

The Jenkins job I wanted to trigger was composed with multi parameters. One is a multi-lines parameters that is too long to exceed the limitation set for the url length in this request.

"""
self.jek_ins.build_job(self.job_name, self.build_vars, self.user_token)
"""

python-jenkins-0.4.8-1.el7.noarch

How to reproduce:
1. pass a parameter including a very long strings to the jenkins params when calling function build_job

Actual Result:
HTTP Error 414: Request-URI Too Long

Excepted result:
Http request for triggering the build succeed even if a long string included.

Revision history for this message
Petr Belskiy (petr.belskiy) wrote :

I have faced with the same problem. It's because python-jenkins uses GET request.

You can use jenkinsapi library for your code, it uses POST request.

Revision history for this message
stellalie (e-ask) wrote :

I have the same problem, I need to send POST request to jenkins with the data in its body. I ended up simply using the undocumented methods `jenkins_open` and `build_job_url` in the mean time:
from six.moves.urllib.request import Request

```
import urllib.parse
import json
import jenkins

server = jenkins.Jenkins(self.server_url)
url = server.build_job_url(job_name)
data = str.encode(urllib.parse.urlencode({'json': json.dumps(params)}))
server.jenkins_open(Request(url, method='POST', data=data))
```

Revision history for this message
Oded Fossfeld (odedfos) wrote :

I get the same problem.
The jenkinsapi package indeed overcomes this issue, however IMO is less robust and moving to it in my case raised some other bugs that needed to be handled.

I could not get the jenkins_open method to work as @stellalie posted, it returns:
HTTPError: 400 Client Error: Nothing is submitted for url
Any idea?

Revision history for this message
liuxun (liuxhit) wrote :

I use airflow with it's jenkins operator using python-jenkins, and I am facing the same ploblem.
With local file on machine modified, I walk around the problem, these is the relevant code:

https://github.com/liuxhit/airflow/blob/main/airflow/providers/jenkins/operators/jenkins_job_trigger.py#L142
"""
request = Request(method='POST', url=jenkins_server.build_job_url(self.job_name, params, None))
"""

https://opendev.org/jjb/python-jenkins/src/branch/master/jenkins/__init__.py#L1349
"""
return (self._build_url(BUILD_WITH_PARAMS_JOB, locals()) +
                    '?' + urlencode(parameters))
"""

I am reading python-jenkins' developer-manual to commit a patch for this problem.

Changed in python-jenkins:
status: New → Confirmed
assignee: nobody → liuxun (liuxhit)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-jenkins (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/jjb/python-jenkins/+/802098

Changed in python-jenkins:
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.