我在多个环境中拥有自托管代理,我试图在这些环境上运行相同的构建/部署进程。我希望能够将相同的代码从单个存储库同时部署到多个系统。因此,我创建了一个“开销”管道和几个“流程”管道模板。一切似乎都进展顺利,除了当我尝试在同一管道执行中两次执行同一存储库的签出时除外。我收到以下错误:
加载 YAML 构建管道时发生错误。已添加具有相同密钥的项目。
我真的希望能够只需单击一个按钮即可触发一个主管道,该管道调用所需的所有模板并提供立即完成所有工作所需的参数。我当然可以定义这个“开销”管道,然后根据需要部署到的每个系统对所需数量的实例进行排队,但我很懒,因此我使用管道!
一旦我从 Common.yml 中删除签出,验证就会成功,没有任何问题。如果我将签出保留在那里,但仅对整个开销管道调用一次 Common.yml,那么它也会成功,没有任何问题。但问题是:我需要将存储库的内容拉到我的每个代理中,这些代理在完全独立的环境中运行,这些环境永远无法相互通信(无法将信息拉到一个代理并拥有它对所有其他代理位置进行某种“复制”......)。
非常欢迎任何帮助,谢谢!
以下是我的“开销”管道:
# azure-pipelines.yml
trigger:
none
parameters:
- name: vLAN
type: string
default: 851
values:
- 851
- 1105
stages:
- stage: vLAN851
condition: eq('${{ parameters.vLAN }}', '851')
pool:
name: xxxxx
demands:
- vLAN -equals 851
jobs:
- job: Common_851
steps:
- template: Procedures/Common.yml
- job: Export_851
dependsOn: Common_851
steps:
- template: Procedures/Export.yml
parameters:
Server: ABTS-01
- stage: vLAN1105
condition: eq('${{ parameters.vLAN }}', '1105')
pool:
name: xxxxx
demands:
- vLAN -equals 1105
jobs:
- job: Common_1105
steps:
- template: Procedures/Common.yml
- job: Export_1105
dependsOn: Common_1105
steps:
- template: Procedures/Export.yml
parameters:
Server: OTS-01
这是“Procedures/Common.yml”:
steps:
- checkout: git://xxxxx/yyyyy@$(Build.SourceBranchName)
clean: true
enabled: true
timeoutInMinutes: 1
- task: UsePythonVersion@0
enabled: true
timeoutInMinutes: 1
displayName: Select correct version of Python
inputs:
versionSpec: '3.8'
addToPath: true
architecture: 'x64'
- task: CmdLine@2
enabled: true
timeoutInMinutes: 5
displayName: Ensure Python Requirements Installed
inputs:
script: |
python -m pip install GitPython
这是“Procedures/Export.yml”:
parameters:
- name: Server
type: string
steps:
- task: PythonScript@0
enabled: true
timeoutInMinutes: 3
displayName: xxxxx
inputs:
arguments: --name "xxxxx" --mode True --Server ${{ parameters.Server }}
scriptSource: 'filePath'
scriptPath: 'xxxxx/main.py'