Nik*_*efi 6 yaml azure azure-pipelines
我喜欢使用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
Run Code Online (Sandbox Code Playgroud)
这就是我连接到另一个存储库的方式:
resources:
repositories:
- repository: SourceRepo
type: git
name: MyCollection/SourceRepo
Run Code Online (Sandbox Code Playgroud)
但我不知道如何从源存储库获取文件并将它们放入目标存储库
Nik*_*efi 11
经过大量搜索,这是答案:
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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15665 次 |
| 最近记录: |