Reputation: 1
For the three vcs supported by circleci, we have observed that for GitHub and BitBucket we are able to access all the endpoints through Postman where the project sulg in the URL is prepared with the "Project Name". Whereas in case of GitLab, the project slug takes "Project ID" instead of the "Project Name" and we could not find the GitLab "Project ID" programmatically through circleci endpoints.
Please help us if there is any way we can get the GitLab Project ID programmatically.
We tried the Organization Summary Metric endpoints but could not find the Project ID in the response.
Upvotes: 0
Views: 319
Reputation: 523
Whereas in case of GitLab, the project slug takes "Project ID" instead of the "Project Name" [...]
It's a project identifier rather than the actual project ID; the project identifier can be seen in the URL of the pipelines page for a given project, along with the organization identifier (this one too is different from the actual organization ID).
For example, if you go to the pipelines page of a specific GitLab-based CircleCI project, you'll see the URL has the following format:
https://app.circleci.com/pipelines/circleci/<organization_identifier>/<project_identifier>
In your API calls related to GitLab projects, you can still use a that follows the format <vcs>/<org>/<project>
. The difference with GitHub/Bitbucket orgs/projects is that for GitLab:
<vcs>
is always circleci
<org>
is the organization identifier, rather than an actual name<project>
is the project identifier rather than the actual repository nameI found that for some API endpoints, you can replace the whole project slug circleci/<organization_identifier>/<project_identifier>
with the actual project ID (i.e, the one you find in the overview section of the project settings)
So for example:
https://circleci.com/api/v2/project/<project_ID>
and
https://circleci.com/api/v2/project/circleci/<organization_identifier>/<project_identifier>
will yield the same output.
Not knowing what your end goal is, I can't provide more specific suggestions. But if you explain in details what you're ultimately trying to achieve, I can try to help.
Edit:
I found out there is an undocumented endpoint you could use to retrieve the projects respective slugs: https://circleci.com/api/private/project?organization-id=your_org_id
.
You can the use those project slugs with any project-related API endpoints.
Upvotes: 1