prkz.de - Blog


Keep it simple

Fixing Not Found (404) error for project scans while setting up Jenkins GitLab Branch Source Plugin

written on 16 April 2021
In my case, we had Jenkins access GitLab through a reverse proxy - nginx. Gitlab was running inside a docker container. I could nicely configure then Jenkins job itself with the GitLab Branch Source Plugin, it even nicely auto-discovered the projects for the owner that I set. However, once it tried to do the "Scan GitLab Project Now", it would give me an error saying "Not found (404)" for the project. For debugging, I ran a `tcpdump -A port 80` in the GitLab container, showing an access path looking like this: ```sh https://my-gitlab.com/projects/my-group/my-project/... ``` Clearly, this didn't match the GitLab API URL for projects, which expects an ":id": [https://docs.gitlab.com/ee/api/projects.html](). It took a long while to figure out, that the API component of the Branch Source Plugin actually URL-encodes the "project path" as the id, i.e. the request URL is actually: ```sh https://my-gitlab.com/projects/my-group%2Fmy-project/... ``` **Turns out, you have to tell nginx to use the original URI as-is (and not automatically unwrap/decode the URI...):** ```sh Wrong: proxy_pass http://127.0.0.1:8929/ Correct: proxy_pass http://127.0.0.1:8929/$request_uri ``` More info in this StackOverflow thread: [https://stackoverflow.com/questions/20496963/avoid-nginx-decoding-query-parameters-on-proxy-pass-equivalent-to-allowencodeds]()