gpt4 book ai didi

Azure Pipeline - 使用 YAML 将文件从一个存储库复制到另一个存储库

转载 作者:行者123 更新时间:2023-12-02 05:54:20 25 4
gpt4 key购买 nike

其中一个存储库(源存储库)中有一个文件夹,我喜欢使用 Azure Pipeline 将其复制到另一个存储库(目标存储库)(因为它们需要同步)

到目前为止,我可以使用以下方法复制同一存储库中的文件夹:

- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\MyFolder\'
Contents: |
**
!**\obj\**
!**\bin\**
TargetFolder: '$(Build.Repository.LocalPath)\DestFolder'
flattenFolders: false
CleanTargetFolder: true
OverWrite: true
preserveTimestamp: true

这是我连接到另一个存储库的方式:

 resources:
repositories:
- repository: SourceRepo
type: git
name: MyCollection/SourceRepo

但我不知道如何从源存储库获取文件并将它们放入目标存储库

最佳答案

经过大量搜索,这就是答案:

resources:
repositories:
- repository: SourceRepo
type: git
name: MyCollection/SourceRepo

steps:

- checkout: SourceRepo
clean: true
- checkout: self
persistCredentials: true
clean: true


- task: DotNetCoreCLI@2
displayName: "restore DestRepo"
inputs:
command: 'restore'
projects: '$(Build.Repository.LocalPath)/DestRepo/**/*.csproj'
feedsToUse: 'select'

- task: DotNetCoreCLI@2
displayName: "build DestRepo"
inputs:
command: 'build'
projects: '$(Build.Repository.LocalPath)/DestRepo/DestRepo/**/*.csproj'
configuration: Release


# configurations for using git command
- task: CmdLine@2
inputs:
script: |
cd $(Agent.HomeDirectory)\externals\git\cmd
git config --global user.email ""
git config --global user.name "$(Build.RequestedFor)"

- task: CmdLine@2
displayName: checkout
inputs:
script: |
git -C RootRep checkout $(Build.SourceBranchName)

- task: CmdLine@2
displayName: pull
inputs:
script: |
git -C DestRepo pull

- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\SourceRepo\SourceFolder'
Contents: |
**
!**\obj\**
!**\bin\**
TargetFolder: '$(Build.Repository.LocalPath)\DestRepo\DestFolder'
flattenFolders: false
CleanTargetFolder: true
OverWrite: true
# preserveTimestamp: true

- task: CmdLine@2
displayName: add
inputs:
script: |
git -C DestRepo add --all

- task: CmdLine@2
displayName: commit
continueOnError: true
inputs:
script: |
git -C DestRepo commit -m "Azure Pipeline Repository Integration"

- task: CmdLine@2
displayName: push
inputs:
script: |
git -C DestRepo push -u origin $(Build.SourceBranchName)

关于Azure Pipeline - 使用 YAML 将文件从一个存储库复制到另一个存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66184369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com