我有一个名为 REPO A 的存储库,并在此处创建了一个 YAML 管道,但我在 REPO B 中也有一些代码,我需要在此管道中使用它们
在 YAML 中,如何告诉 REPO A 中的管道使用 REPO B 中的文件/文件夹?
我是这方面的新手,所以你能简单点吗?
resources:
repositories:
- repository: automation
type: git
name: MYORG/ automation
ref: develop
endpoint: YourEndpoint
steps:
- checkout: self
path: "s/Source" : ***>>>>>> what should this be??***
- checkout: automation
最佳答案
好的,只需放在我添加的 yaml 的顶部即可
> resources:
> repositories:
> - repository: automation
> type: git
> name: name of yourpoject/name of repo you want to use
> ref: whatever branch of that repo(under repository above) you want to use
然后!!在 YAML 中的步骤下(如果您没有,则需要添加它!)
> steps:
> - checkout: self
> - checkout: your repository you want to use as above
此外,如果您使用 npm 运行任务,您还需要添加以下内容,以免出现任何文件未找到错误!如果不添加以下代码,常见错误是:npm WARN saveError ENOENT:没有这样的文件或目录,打开'/home/vsts/work/package.json
下面的代码放在-Task部分
> > npm install
> > displayName: 'a task using npm'
> > workingDirectory: '$(Build.SourcesDirectory)/your repository you want to use as above
在 YAML 中插入代码时还要注意缩进,如果缩进不正确,会很烦人而且很痛苦,它会给你错误,只需按 Tab 键直到它们消失
关于azure-devops - 在 Azure Devops 中运行管道时如何包含其他存储库中的文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71939815/