Jenkins coverage badge generation fails if Jenkins server's default language is not English
- Dominant language
- JavaScript
- Stars
- 27.2k
- Forks
- 5.6k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 46
Description
Are you experiencing an issue with...
- [x] [shields.io](https://shields.io/#/)
- [ ] My own instance
- [ ] [badge-maker NPM package](https://www.npmjs.com/package/badge-maker)
:beetle: **Description**
Our Jenkins server does not have the locale plugin installed, and therefore is using the machine's default language as default language, which is Spanish.
This means that [this query's](http://jenkins.eprosima.com:8080/job/nightly_fastdds_coverage_linux/lastSuccessfulBuild/cobertura/api/json/?depth=2)
language response depends on the `Accept-Language` field of the HTTP header.
If the query is performed directly in the browser, the header is added, and so if the browser is configured in English, then the result is in English and the coverage badge can be generated.
However, if `Accept-Language` is not specified, Jenkins responds in its default language, so my coverage response looks like
```json
{
"_class":"hudson.plugins.cobertura.targets.CoverageResult",
"results":{
"children":[...],
"elements":[
{
"denominator":112.0,
"name":"Paquetes",
"numerator":111.0,
"ratio":99.10714
},
{
"denominator":434.0,
"name":"Ficheros",
"numerator":422.0,
"ratio":97.23502
},
{
"denominator":434.0,
"name":"Clases",
"numerator":422.0,
"ratio":97.23502
},
{
"denominator":41695.0,
"name":"LÃ\xadneas",
"numerator":32987.0,
"ratio":79.115005
},
{
"denominator":65298.0,
"name":"Condicionales",
"numerator":22829.0,
"ratio":34.961254
}
],
"name":"Cobertura Coverage Report"
}
}
```
:link: **Link to the badge**
:bulb: **Possible Solution**
For the badge generation to work with Jenkins servers defaulting to languages other than English, the query to the job's coverage report should specify `"Accept-Language": "en-US,en;q=0.9"` in the HTTP header.
Of course setting the server to always respond in English will solve the issue, but that's something that is not always possible to do depending on the privileges.
I'm sorry about not issuing a PR myself, but I don't know the project and I don't have enough time at the moment.
Contributor guide
Research direction
Start by tracing the Jenkins coverage badge request that calls the linked Cobertura API endpoint. Compare the response with and without the Accept-Language header, then verify the badge generation against a server whose default language is Spanish. Done means the Jenkins coverage badge works without requiring the server's locale to be English.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100