Send specific files from Azure DevOps pipeline to Github

前提是你 提交于 2021-01-29 07:44:35

问题


I am looking for a good solution to send a specific file (or a range of files) to a private GitHub repo from Azure DevOps pipeline.

You might ask why I would like to copy a file from one git to another git. But we are using Swagger to document our API, and to show Swagger UI on Confluence it can read the swagger.json from a private repo on GitHub. As far as I know Confluence cannot read the json directly from Azure DevOps.

I've tried to use the extension GitHub Release in Azure DevOps, but I don't want to create a specific release on GitHub, I just want to update specific json files.


回答1:


You could have a PowerShell task in your pipeline to execute your requirement. Example below:

#Clone repo to your workspace
git clone https://github.com/repo

#assuming master is your branch
git checkout master

#Refresh repo if is already in your workspace
git pull -q 2>&1 | Write-Host

#Copy file to the worspace
XCOPY "File current location" "Git workspace location"

#Add files to the local repo
git add -A

#Commits the file to local repo:
git commit -m "Files commited."

#Pushes the changes to Git repo
git -c http.extraheader='AUTHORIZATION: bearer $env:System_AccessToken' push -q -f


来源:https://stackoverflow.com/questions/58510901/send-specific-files-from-azure-devops-pipeline-to-github

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!