NPM对另一个私有Bitbucket存储库Azure DevOps管道身份验证的依赖关系失败 [英] NPM dependencies to another private Bitbucket repo Azure DevOps pipeline authentication fails

查看:58
本文介绍了NPM对另一个私有Bitbucket存储库Azure DevOps管道身份验证的依赖关系失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为项目开发Azure DevOps构建管道.除了azure-pipeline.yaml文件之外,我无法对代码本身进行任何更改.(老实说,我对项目本身知之甚少)

我陷入了NPM安装依赖项步骤.我目前正在使用YAML管道,但是如果有经典模式下的解决方案,我会继续使用.

问题如下:

我创建了管道,并根据文档检查了一个私有的Bitbucket存储库:

 资源:仓库:-存储库:MyBitBucketRepo1类型:位桶端点:MyBitBucketServiceConnection名称:MyBitBucketOrgOrUser/MyBitBucketRepo 

下一步,我设置正确的节点版本,并执行 npm install 任务

 -任务:Npm @ 1displayName:"NPM安装"输入:命令:安装"workingDir:工作目录" 

到目前为止,一切都很好.但是,它依赖于另一个Bitbucket存储库.在package.json中,有一个像这样的依赖项:

 另一个依赖项:git:https://bitbucket.org/organisation/repo.git#v1.1.3 

我确实有权访问该存储库,但是如果我运行NPM安装,它将无法重新使用第一个存储库中的凭据.

我尝试将两个存储库都添加到 resources 中,以期能奏效.但仍然是相同的错误:

 错误致命:'https://bitbucket.org/organisation/repo.git/'的身份验证失败 

我试图建立一些缓存机制,在第二个仓库中运行 npm install ,存储依赖项,在第一个仓库中运行 npm install .但是不幸的是,这没有用.

Azure Devops管道中是否有一种方法-无需更改项目设置即可完成这项工作?

谢谢!

解决方案

通常,我在存储库上有.npmrc,因此我不必添加任何其他任务.本指南中的内容:

尝试一下,告诉我是否有帮助!

I'm working on a Azure DevOps build pipeline for a project. I can't make any changes to the code itself besides the azure-pipeline.yaml file. (And to be honest, I know very little about the project itself)

I'm stuck on the NPM install dependencies step. I'm currently working with the YAML pipeline, but if there's a solution in the classic mode I'll go with that.

The issue is the following:

I've created the pipeline with and I check out a private Bitbucket repository according to the documentation:

resources:
  repositories:
  - repository: MyBitBucketRepo1
    type: bitbucket
    endpoint: MyBitBucketServiceConnection
    name: MyBitBucketOrgOrUser/MyBitBucketRepo

Next I set the correct version of node, and execute a npm install task

- task: Npm@1
  displayName: 'NPM install'
  inputs:
    command: 'install'
    workingDir: 'the working directory'

So far so good. But, there is a dependency to another Bitbucket repository. In the package.json there is a dependecy like this:

another-dependency: git:https://bitbucket.org/organisation/repo.git#v1.1.3

I do have access to this repository, but if I run NPM install it can't re-use the credentials from the first repository.

I've tried adding both repositories to the resources in the hope that would work. But still the same error:

error fatal: Authentication failed for 'https://bitbucket.org/organisation/repo.git/'

I've tried to set up some caching mechanism, run npm install on the 2nd repo, store the dependencies, run npm install on the first one. But that didn't work unfortunately.

Is there a way in Azure Devops pipelines -without making changes to the project set-up- to make this work?

Thanks!

解决方案

Normally I have the .npmrc on the Repo so I dont have to add any other task. Something like in this guide: https://docs.microsoft.com/en-us/azure/devops/artifacts/get-started-npm?view=azure-devops&tabs=windows

And I never do something like that, but I think that you can authenticate with the external feed adding this task: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/npm-authenticate?view=azure-devops

Reading a bit more, I dont know if you can do this without adding a .npmrc on your Repo. You have to create a ServiceConnection to store your login credentials, but on that you will need the .npmrc on your Repo.

Try it and tell my if this help!!

这篇关于NPM对另一个私有Bitbucket存储库Azure DevOps管道身份验证的依赖关系失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆