将特定文件从Azure DevOps管道发送到Github

将特定文件从Azure DevOps管道发送到Github,github,azure-devops,swagger,Github,Azure Devops,Swagger,我正在寻找一个好的解决方案,从Azure DevOps管道将特定文件(或一系列文件)发送到私有GitHub repo 您可能会问我为什么要将文件从一个git复制到另一个git。但是我们正在使用Swagger来记录我们的API,为了在Confluence上显示Swagger UI,它可以从GitHub上的私有repo读取Swagger.json。据我所知,Confluence无法直接从Azure DevOps读取json 我尝试在Azure DevOps中使用扩展GitHub版本,但我不想在Git

我正在寻找一个好的解决方案,从Azure DevOps管道将特定文件(或一系列文件)发送到私有GitHub repo

您可能会问我为什么要将文件从一个git复制到另一个git。但是我们正在使用Swagger来记录我们的API,为了在Confluence上显示Swagger UI,它可以从GitHub上的私有repo读取Swagger.json。据我所知,Confluence无法直接从Azure DevOps读取json


我尝试在Azure DevOps中使用扩展GitHub版本,但我不想在GitHub上创建特定版本,我只想更新特定的json文件。

您可以在管道中使用PowerShell任务来执行您的需求。示例如下:

#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

这看起来很有希望,让我来设置并测试它!嗨,最近怎么样?powershell任务是否有助于实现您的目标?如果是,您可以接受答案,这样其他用户就可以看到解决方案是否有效。如果您仍然面临一些问题,请随时离开此处:-)