How to use gitlab repo in NPM with package. json

I am working on an internal project and want to share tools within the group.

but if i use npm tools. he either requests the module to register on the npm website or the git public repository.

I am 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 this way in package.json but it does not work.

Is there a way to set up gitlab private repositioning with authorization?

Many thanks.

+4
source share
2 answers

If I understand your question correctly, you want your CI pipeline that started npm to be able to pull a private project from your gitlab as a dependency.

gitlab (. ).

SSH. ssh-keygen -t rsa .

gitlab Deploy Keys. , .

, npm CI, Variables. SSH_PRIVATE_KEY, , , .

, .gitlab-ci.yml , CI:

- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

CI , .

+9

git + ssh " "

/ , " ".

package.json ( , /).

package.json

"module-name": "git+ssh://git@gitlab.domain.com:group/repo.git"

premature close

0

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


All Articles