shields.io with self-host gitlab & private repo

Created on 3 Feb 2019  ·  17Comments  ·  Source: badges/shields

Are you experiencing an issue with...

  • [x] [shields.io](https://shields.io/#/)
  • [ ] My own instance
  • [ ] [gh-badges NPM package](https://www.npmjs.com/package/gh-badges)

:beetle: Description


I used my own gitlab instance and private repo. When I used with shield.io, the link is: https://img.shields.io/badge/dynamic/json.svg?label=build&colorB=brightgreen&&query=$.last_pipeline.status&url=https://${gitlab_url}/api/v4/projects/${projects_id}/repository/commits/master?private_token=${private_toke}
but it always shows
image
And I confirm that url with my gitlab_url has correct answer with json format
image

UPDATE:
When url link is ecc certificate, it will show inaccessible. But when you use rsa certificate, it will be ok.

:link: Link to the badge

:bulb: Possible Solution

question

All 17 comments

Hi! Could the problem be that the URL parameter isn't encoded correctly? You could use this form: https://www.urlencoder.org/

When I used encoded url after url= , like
https://img.shields.io/badge/dynamic/json.svg?label=build&colorB=brightgreen&&query=$.last_pipeline.status&url=https%3A%2F%2F${gitlab_url}%2Fapi%2Fv4%2Fprojects%2F${project_id}%2Frepository%2Fcomm
its%2Fmaster%3Fprivate_token%3D${private_token}

It also shows inaccessible

There's a double && in there that should be a single &. And maybe URL-encode the query too?

I have tried a single & and url_encode the query, like this link:
https://img.shields.io/badge/dynamic/json.svg?label=build&colorB=brightgreen&query=%24.last_pipeline.status&url=https%3A%2F%2F${gitlab_url}%2Fapi%2Fv4%2Fprojects%2F7%2Frepository%2Fcommits%2Fmaster%3Fprivate_token%3D${private_toke}

but nothing changes, also shows inaccessible

It's hard to debug this further without a working example.

One suggestion: if you start the server with TRACE_SERVICES=true and then make the request, you should get a bunch of log output which may help you troubleshoot further.

I used public shield.io not self-host

Perhaps this would be more easily accomplished using the new Endpoint service badge (https://github.com/badges/shields/issues/2838)?

It looks like with this current approach you are hardcoding the badge color to brightgreen, regardless of the pipeline status. If you deployed a custom endpoint it might make debugging a bit easier and allow for some custom logic around status, etc.

I have try to delete &colorB=brightgreen in the links, but no changes.

I was actually suggesting that instead of using the dynamic json badge (which you are currently using), that you should consider trying the new endpoint badge type instead (https://shields.io/#/endpoint).

I was not suggesting removing the colorB query parameter from the url

When I try with endpoint with json file, it also show inaccessable

When I try with endpoint with json file, it also show inaccessable

Sorry I don't understand what you mean. If you have developed, and deployed a custom endpoint that you are using with the Endpoint badge, can you please share the link to your Endpoint?

Now I use this link: https://img.shields.io/badge/endpoint.svg?url=https://badge.kellyok.tk/dnsmasq/build.json

I found the problem, If use ecc certificate in url, it will show inaccessable, but if use rsa certificate, it's ok, no problem.

Huh, I wonder if that's related to #2812.

So how can i solve this problem? Just drop ecc certificate and use old rsa certificate?

We'll work on updating our Node client in #2812 which might help, and hopefully will add our own GitLab badges in #2771, which could then be used with self-hosting for private repos.

Beyond that, there isn't enough information here to solve this. I'm sorry.

this works:

h_t_t_p_s://img.shields.io/badge/dynamic/json?color=blue&label=your_label&query=json_path&url=https%3A%2F%2Fyour_host%2Fapi%2Fv4%2Fprojects%2F%{project_id}%2Frepository%2Ffiles%2Ffilename%252Eextension%2Fraw%3Fref%3Dbranch%26private_token%3Dyour_token

example:

h_t_t_p_s://img.shields.io/badge/dynamic/json?color=blue&label=version&query=version&url=https%3A%2F%2Fyour_host%2Fapi%2Fv4%2Fprojects%2F%{project_id}%2Frepository%2Ffiles%2Fversion%252Ejson%2Fraw%3Fref%3Dmaster%26private_token%3Dyour_token

^ this extracts the version property from a file version.json in the master branch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yvele picture yvele  ·  33Comments

agemooij picture agemooij  ·  27Comments

paladox picture paladox  ·  72Comments

sinedied picture sinedied  ·  28Comments

ducin picture ducin  ·  51Comments