Installing private dependencies via npm in a VS Team Services CI build

前端 未结 2 1181
北恋
北恋 2021-01-28 18:39

I\'m setting up some CI builds of NodeJS projects in VS Team Services. I currently have four projects being cloned from private Github repositories, running npm install

相关标签:
2条回答
  • 2021-01-28 19:10

    Recently i needed to do this in Azure Devops on a Windows based agent, Instead of changing dependencies to include user and token in the packages.json, it was easier to create a build step to add the authentication information from environment variables to windows credentials store and instructing git to use that.

    git config --global credential.helper wincred
    cmdkey /generic:LegacyGeneric:target=git:https://our-private-domain.com /user:git-readonly-use@our-private-domain.com /pass:"Personal Access Token With Read Permissions"
    

    After adding these configurations, Npm installs that we were doing using a script in source code went through without any issue

    "dependencies": {
    "example-1": "git+https://our-private-domain.com/proj/example-1.git#v0.1.9",
    "example-2": "git+https://our-private-domain.com/proj/example-2.git#master"
    }
    
    0 讨论(0)
  • 2021-01-28 19:23

    The problem is that the build agent will not able to authenticate because of lack of SSH keys on the build agent and because the host verification will fail anyway.

    Instead you should create a Personal Access Token on GitHub with 'repo' only scope, then you should use it on your packages.json file (notice that ssh is replaced with https protocol):

    "project-name": "git+https://<user>:<token>@github.com/my-org/project-name.git#master",
    
    0 讨论(0)
提交回复
热议问题