github - 将特定文件从 Azure DevOps 管道发送到 Github
问题描述
我正在寻找一个很好的解决方案,将特定文件(或一系列文件)从 Azure DevOps 管道发送到私有 GitHub 存储库。
你可能会问我为什么要将文件从一个 git 复制到另一个 git。但是我们使用 Swagger 来记录我们的 API,并在 Confluence 上显示 Swagger UI,它可以从 GitHub 上的私有 repo 中读取 swagger.json。据我所知,Confluence 无法直接从 Azure DevOps 读取 json。
我尝试在 Azure DevOps 中使用扩展 GitHub Release,但我不想在 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
推荐阅读
- python - 格式化满足条件的行 Pandas Python
- macos - 新的 Mac M1 (ARM) 芯片如何安装 QMK
- php - 仅获取当前月份的两个日期之间的天数
- c - 我无法在 C 中执行代码 | 某种不显示的错误
- javascript - 您可以在 calc 中访问 css 类自己的属性吗?
- x86-64 - 为什么循环从 Uop Cache 提供的 uops 过渡到 LSD 会导致分支未命中率激增?
- android - 科尔多瓦模拟android和Gradle的问题
- json.net - JSON.net 将 json 文本从平面反序列化为嵌套对象
- join - 使用 TMap 从多个表验证 talend 外键是否存在
- python - 如何在 LightGBM 中为 linear_tree=True 访问线性模型