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

shields.io with self-host gitlab & private repo #2911

Closed
1 of 3 tasks
gkl1368 opened this issue Feb 3, 2019 · 17 comments
Closed
1 of 3 tasks

shields.io with self-host gitlab & private repo #2911

gkl1368 opened this issue Feb 3, 2019 · 17 comments
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas

Comments

@gkl1368
Copy link

gkl1368 commented Feb 3, 2019

Are you experiencing an issue with...

🪲 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 to the badge

💡 Possible Solution

@paulmelnikow
Copy link
Member

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

@gkl1368
Copy link
Author

gkl1368 commented Feb 3, 2019

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

@paulmelnikow
Copy link
Member

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

@paulmelnikow paulmelnikow added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Feb 3, 2019
@gkl1368
Copy link
Author

gkl1368 commented Feb 3, 2019

@paulmelnikow
Copy link
Member

paulmelnikow commented Feb 3, 2019

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.

@gkl1368
Copy link
Author

gkl1368 commented Feb 3, 2019

I used public shield.io not self-host

@calebcartwright
Copy link
Member

Perhaps this would be more easily accomplished using the new Endpoint service badge (#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.

@gkl1368
Copy link
Author

gkl1368 commented Feb 3, 2019

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

@calebcartwright
Copy link
Member

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

@gkl1368
Copy link
Author

gkl1368 commented Feb 3, 2019

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

@calebcartwright
Copy link
Member

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?

@gkl1368
Copy link
Author

gkl1368 commented Feb 4, 2019

@gkl1368
Copy link
Author

gkl1368 commented Feb 4, 2019

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

@paulmelnikow
Copy link
Member

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

@gkl1368
Copy link
Author

gkl1368 commented Feb 4, 2019

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

@paulmelnikow
Copy link
Member

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.

@jgroom33
Copy link

jgroom33 commented Mar 27, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas
Projects
None yet
Development

No branches or pull requests

4 participants