Here is my scenario:
I have a scenario where after a successful git push to a deployment folder (SSIS and TSQL scripts) in azure repos, I have to move the files in deployment folder to multiple archival folders inside the repos(SSIS and TSQL) after successful build. I need to achieve this with azure devops build and release process. any help is really appreciated.
You could use CopyFiles
task and git command to copy and push files in the repo. Check the sample below:
steps:
- checkout: self
persistCredentials: true
- task: CopyFiles@2
inputs:
SourceFolder: 'deployment'
Contents: '**'
TargetFolder: '$(Build.SourcesDirectory)/archival1'
- task: CopyFiles@2
inputs:
SourceFolder: 'deployment'
Contents: '**'
TargetFolder: '$(Build.SourcesDirectory)/archival2'
- script: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git checkout master
git add $(Build.SourcesDirectory)/archival1/** $(Build.SourcesDirectory)/archival2/**
git status
git commit -m "copy files"
git push origin master
If you want to delete the deployment
folder after copying the files, you could add the following to the pipeline:
- task: DeleteFiles@1
inputs:
SourceFolder: 'deployment'
Contents: '**'
RemoveSourceFolder: true
- script: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git checkout master
git add $(Build.SourcesDirectory)/deployment/**
git status
git commit -m "delete deployment folder"
git push origin master
Notice:
You need to grant version control permissions to the build service: