简体   繁体   English

将更改推送到 GitHub 存储库作为 Azure DevOps 中发布管道的一部分

[英]Push changes to GitHub repository as a part of release pipeline in Azure DevOps

I am trying to create a Release pipeline that:我正在尝试创建一个发布管道:

  1. Updates the docker image in the docker-compose.yml that is a part of my deployment repository更新 docker-compose.yml 中的 docker 镜像,它是我的部署存储库的一部分
  2. Logs via SSH to my server通过 SSH 登录到我的服务器
  3. [On my remote server] fetches the latest deployment repository [在我的远程服务器上] 获取最新的部署存储库
  4. [On my remote server] runs the updated docker-compose.yml [在我的远程服务器上] 运行更新的 docker-compose.yml

I stuck on the point #1.我坚持第 1 点。 I managed to get to the point where I have my repository available, I update the docker-compose.yml file (via bash script), I can commit the changes but unfortunately the push fails.我设法让我的存储库可用,我更新了 docker-compose.yml 文件(通过 bash 脚本),我可以提交更改但不幸的是推送失败。

Here's my release pipeline with two artifacts:这是我的发布管道,包含两个工件:

  1. my build pipeline which I'm using to get the build number that I want to release我的构建管道,我用它来获取我想要发布的构建号
  2. my GitHub repository (since I'm using 2FA, I've linked it via Personal Token)我的 GitHub 存储库(因为我使用的是 2FA,所以我通过 Personal Token 链接了它)

管道定义

Here's my stage with three bash scripts - the first two are updating docker-compose.yml, the third one should commit the changes to the repository and push it.这是我使用三个 bash 脚本的阶段 - 前两个是更新 docker-compose.yml,第三个应该将更改提交到存储库并推送它。

阶段定义

Here's the result I'm getting when running the release:这是我在运行发布时得到的结果:

在此处输入图片说明

It seems there's some problem with authentication when doing git push, but I'm not sure how to solve this.似乎在执行 git push 时身份验证存在一些问题,但我不确定如何解决此问题。 This SO suggests it's a problem with 2FA enabled on the git side, but since I'm using Personal Access Token to authenticate to git, 2FA should not be used.SO表明这是一个问题,在git的侧启用2FA,但因为我使用的个人访问令牌来验证混帐,2FA不宜使用。 Even if I add this line to my script as suggested in that SO:即使我按照该 SO 中的建议将此行添加到我的脚本中:

git config --global --add url."git@github.com:".insteadOf "https://github.com/"

It still fails with the following error:它仍然失败并出现以下错误:

Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Could anyone guide me how to properly push git repository as a part of Azure release pipeline?谁能指导我如何将 git 存储库作为 Azure 发布管道的一部分正确推送?

I found a workaround that seems to solve my problem.我找到了一种解决方法,似乎可以解决我的问题。 I have removed the repository from the artifacts list and instead I'm doing everything manually:我已从工件列表中删除了存储库,而是手动执行所有操作:

  1. Installing SSH key (via native Install SSH Key task)安装 SSH 密钥(通过本机安装 SSH 密钥任务)
  2. Cloning the repository using SSH key (via Bash script)使用 SSH 密钥克隆存储库(通过 Bash 脚本)
  3. Executing all the logic执行所有逻辑
  4. Cleaning up the repository (not sure this is needed, but to be on the safe side...)清理存储库(不确定是否需要,但为了安全起见......)

阶段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Azure Devops中为基于Python的Azure Function设置发布管道的正确方法 - Proper way to set up a release pipeline in Azure Devops for Python based Azure Function 在 Azure DevOps 管道中找不到 Pytest - Pytest not found in Azure DevOps Pipeline 如何使用 Bash 将资产从 Azure 发布管道上传到 Github Enterprise - How to upload an asset from Azure Release pipeline to Github Enterprise using Bash Azure DevOps 管道在运行 pylint 时失败 - Azure DevOps pipeline fails when running pylint Azure Devops 使用仓库名称获取repositoryId - Azure Devops Get a repositoryId by using repository name 如何使用 GitHub Actions 在管道中 git push 到 GitHub - How to git push to GitHub in a pipeline using GitHub Actions 如何在 azure 构建到发布管道中将变量从构建传递到发布 - How to pass variable from build to release in azure build to release pipeline Git推送到未反映更改的裸仓库 - Git push to bare repository not reflecting changes 如何在 azure devops 管道中使用 arguments 运行 bash 脚本? - How to run a bash script with arguments in azure devops pipeline? Azure Devops terraform 管道生成客户端 ID 和机密 - Azure devops terraform pipeline generate client id and secret
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM