Get gitlab-ci token with gitlab API

It is not clear from the API how to get a token that can be used to clone http repositories.

From the documentation here:

http://doc.gitlab.com/ee/ci/api/README.html

It should be possible to GET this URL:

http://gitlab.com/ci/api/v1/projects?private_token=QVy1PB7sTxfy4pqfZM1U&url=http://demo.gitlab.com/

I'm not sure where the parameter comes from, urlbut even with my personal token, it gets a 404 error page.

I tried with a subdomain cibut it just redirected me to gitlab.com.

However, I will explain a little more reasons why I need it. I have a server that can have multiple projects. Each project will contain a list of private / public repositories, each project must be cloned / extracted, etc. Regularly. Unlike github, gitlab does not provide the oauth2 token that is nearby, and instead provides a CI token for each project. I could make sure that the user enters a token for each project, but this is much more complicated than entering a personal token.

On the other hand, I could generate SSH keys for each user and add the public key to their account, and in this way I could get / clone using ssh instead of http. But this is a bit more work on my part than just getting the token and cloning with the main authentication URL.

git clone https://gitlab-ci-token:token@gitlab.com/project.git
+8
source share
4 answers

The URL to receive your token is located at the following path / profile / account .

Or you can simply go to Profile Settings โ†’ Account

, api. v3/api/v3/projects? Private_token = {my_private_token}

+3

, .

  • ? โ†’ .

  • , CI/CD, , โ†’ CI/CD โ†’

, , Git.

+1

Gitlab CI, HTTPS . SSH.

:

git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/<group_name>/<repo>.git

, CI_JOB_TOKEN. . , <group_name> <repo>.

, gitlab.com gitlab.xyz.cloud ( gitlab), .

, CI_JOB_TOKEN

0

, gitlab.com

  1. , ,
  2. "" .
  3. "CI/CD",
  4. ""
  5. .

It took me 10 minutes to find this ... not documented anywhere.

-1
source

Source: https://habr.com/ru/post/1624726/


All Articles