将特定文件从Azure DevOps管道发送到Github [英] Send specific files from Azure DevOps pipeline to Github

查看:56
本文介绍了将特定文件从Azure DevOps管道发送到Github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种很好的解决方案,以将特定文件(或一系列文件)从Azure DevOps管道发送到私有GitHub存储库.

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.

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

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.

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

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.

推荐答案

您可以在管道中包含一个PowerShell任务来执行您的需求.下面的示例:

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

这篇关于将特定文件从Azure DevOps管道发送到Github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆