is it possible to use Gitlab API for official Gitlab Server? I mean www.gitlab.com. I can't find the host URI. Here is the api:
https://docs.gitlab.com/ce/api/
While the documention does mention https://gitlab.example.com/api/v3/..., you are still able to apply that API to gitlab.com itself.
You would use urls like https://gitlab.com/api/v3/... as described in this issue
https://gitlab.com/api/v3/projects?private_token=...
Or here (for creating a new project):
curl --header "PRIVATE-TOKEN: my token" -d "name=test" "https://gitlab.com/api/v3/projects"
Related
I know there is an API for getting repository content. But my use case is I need to get the whole repository and display it in my UI like GitHub UI. Similar to GitHub UI, I need my repository to be displayed in my UI. Is there any API I can use to get the whole repository so I can display that in my UI.
I tried this API.
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/repos/OWNER/REPO/zipball/REF
But it gives separate file contents. I need the whole repo.
Getting the all repository remains easier with a simple git clone. No need for an API call there.
If, as mentioned in this 2016 octokit issue, you cannot clone through GitHub API, you could use libgit2sharp to integrate the clone operation in your application.
Is there an API in gitlab that can fetch the issues mentioned in the merge request? I keep looking at the documentation, but I can't find it.
I'd like to take advantage of this and try to automate it.
Maybe the Gitlab merge request API is what you need https://docs.gitlab.com/ee/api/merge_requests.html#list-issues-that-close-on-merge
You can get all the issues that would be closed by merging the provided merge request.
GET /projects/:id/merge_requests/:merge_request_iid/closes_issues
Example command:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/<project_id>/merge_requests/<merge_request_id>/closes_issues"
I am trying to list the files present on an enterprise GitHub repository. I tried using GitHub API but base URL for it is
api.github.com where as base URL would be different for me and when I put that URL it says couldn't resolve. How can I achieve it for a URL in below format
https://company.net/org/reponame
Below example works for me but the URL that I have it doesn't work
curl -k https://api.github.com/user/repo?refs=master
For an on-premise GitHub Enterprise, the documentation mentions
REST API endpoints — except Management Console API endpoints — are prefixed with the following URL:
http(s)://[hostname]/api/v3
In your case: https://company.net/api/v3
From there, using the Git Database API -- list tree, you can list all files, as illustrated here.
I'm trying to download a raw file from one of my IBM Cloud Git Repos and Issue Tracking repositories. I had a script that was able to fetch raw file contents using the following curl command:
curl -H "Private-Token: $PERSONAL_ACCESS_TOKEN" https://git.ng.bluemix.net/:owner/:repo/raw/:branch/:filename
but it recently started failing with a 302 response that is redirecting to a UI login page.
Is there a supported way to download raw file contents from an IBM Cloud Git Repos and Issue Tracking repository?
The curl request above is attempting to use a personal access token to authenticate to a UI endpoint. There was a security fix in GitLab 11.3.11 that limited the scope of personal access tokens to API calls only. That would explain why personal access tokens are no longer working on that request.
The supported method of downloading raw file contents would be to call the repository files API.
For example, to fetch myFolder/myFile.txt from the master branch of myRepo, owned by myUser, you can make a curl call like this:
curl -H "Private-Token: $PERSONAL_ACCESS_TOKEN" https://git.ng.bluemix.net/api/v4/projects/myUser%2FmyRepo/repository/files/myFolder%2FmyFile.txt/raw?ref=master
How do I do dashboard with information from my GitLab repo? I don't know how I get information about builds, commits and files and create dashboard with this information. Any idea? Thank you very much.
You can use GitLab's API to obtain the information from GitLab. You will need to have an user account which can access a particular project. Get this user's "Private Token" from the /profile/account page and then you can make requests for which you would get a JSON response.
Retrieving latest commits
curl -H "PRIVATE-TOKEN: [TOKEN]" \
"https://[HOST]/api/v3/projects/[PROJECT ID]/repository/commits"
Retrieving latest builds
curl -H "PRIVATE-TOKEN: [TOKEN]" \
"https://[HOST]/api/v3/projects/[PROJECT ID]/repository/builds"
These are examples using curl. Depending on the programming language you are going to use, you will have to make a GET request while setting a HTTP header (that is what -H in my example stands for) named PRIVATE-TOKEN.