I use GitLab on their servers. I would like to download my latest built artifacts (build via GitLab CI) via the API like this:
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.com/api/v3/projects/1/builds/8/artifacts"
Where do I find this project ID? Or is this way of using the API not intended for hosted GitLab projects?
To find the project number, look at the project URL. For example, https://github.com/orgs/octo-org/projects/5 has a project number of 5. You can also find the node ID of all projects in your organization.
To locate your personal GitLab API key, first navigate to the GitLab User Settings from the main menu. Then click on Access Tokens in the left side menu. Give a descriptive name for your token, select the “api” scope and finally click on the Create personal access token button.
If you're a GitLab.com user, the base URL is https://gitlab.com . If you're hosting your own GitLab instance, the base URL depends on your domain configuration so you may need to consult your GitLab admin in case you're unsure (although it's ok to use a trial and error too.
I just found out an even easier way to get the project id: just see the HTML content of the gitlab page hosting your project. There is an input with a field called project_id, e.g:
<input type="hidden" name="project_id" id="project_id" value="335" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With