I'm working on a internal project and want to share a tools inside the group.
but if I use the npm tools. it either request the module has registered on npm website or public git repo.
I'm using gitlab. and there is a private token.
git+https://gitlab-ci-token:\<private token>@<domain>/<username>/<repo_name>.git
i tried to put it like this in package.json
but it's not working.
Is there a way to install a private gitlab repo with authorization?
thanks a lot.
If I understand your question correctly, you want your CI pipeline which runs npm to be able to pull a private project from your gitlab as a dependency.
In that case, you can use the deploy keys mechanism in gitlab for that (see here).
First generate a SSH key pair. You can use
ssh-keygen -t rsa
for that.Then go to the private repository's gitlab page and locate the
Deploy Keys
setting. There you should paste the public key you just generated.Then go to the project that runs npm in its CI and locate the
Variables
page. Create a new private variable with the nameSSH_PRIVATE_KEY
for instance and paste the private key you generated there.Finally, in your
.gitlab-ci.yml
file add the following so that your private key will be available to your CI environment:Your CI environment should now be setup so that in can pull your private repository.