I am building a yml pipeline in azure devops to copy a folder from a azure windows machine directly to the git repository
I first used checkout module and downloaded repository onto the server
- checkout: self
Then tried below commands after copying the files in the checkout folder.
- task: CmdLine@2
inputs:
script: |
cd $(Build.Repository.LocalPath)
git config --global user.name "xxx"
git config --global user.email "xx"
git checkout -b test
git add --all
git commit -m "samplecode"
git push origin -u "test"
Got below error
Switched to a new branch 'test'
[test ] test
1 file changed, 1 insertion(+)
create mode 100644 folder/filename.txt
fatal: Cannot determine the organization name for this 'xx.com' remote URL. Ensure the `credential.useHttpPath` configuration value is set, or set the organization name as the user in the remote URL '{org}@xx.com'
Is there any other way to do this or any direct devops module exist for copying files from server to repository directly
You can try like as below:
In the YAML pipeline, on the checkout task, you need to set 'persistCredentials
' to 'true
' so that the git
commands in the subsequent tasks can directly use the same credentials as the checkout task. Otherwise, you need to provide the extra credentials to the git
commands in the subsequent tasks.
- checkout: self
persistCredentials: true
Then after the checkout task, you can use a Bash task to run the related commands to copy, commit and push the folders/files. And you also can add the command line "git config --global credential.{remote URL}.useHttpPath true
" before commit and push the changes.
git config --global user.name "xxx"
git config --global user.email "xx"
git config --global credential.{remote URL}.useHttpPath true
If the remote git repository is on Azure DevOps, the value of {remote URL}
can be "https://dev.azure.com
". If on GitHub, the value can be "https://github.com
".