将更新从 azure 推送到 github [英] push updates from azure to github

查看:25
本文介绍了将更新从 azure 推送到 github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 azure devops 的新手,面临着在 azure devops 和 github 之间集成的问题,也许你能帮忙.我的问题是如何将在 azure devop 存储库上完成的提交推送到驻留在我的 github 帐户上的相应存储库?

i am new to azure devops and facing problem to integrate between azure devops and github, may be you could help. my question is how can i push commits that are done on the azure devop repo to corresponding repo which resides on my github account?

例如:1)我从github私有仓库导入一个文件abc.py2)我在 azure devops repo 中对 abc.py 进行了更改并提交.3) 现在,我在 azure repo 的 master 分支上对 abc.py 所做的所有提交都应该推送到我以前导入的私有 github 仓库中的 master 分支的 abc.py.

For example: 1)i import a file abc.py from github private repo 2)i make changes to abc.py in azure devops repo and commits it. 3)now all the commits i made to abc.py on master branch of azure repo should be pushed to abc.py of master branch in my private github repo from where it was previously imported.

感谢您的帮助.

推荐答案

您可以尝试在构建管道的代理作业中添加一个命令行脚本任务,然后通过以下方式将更新推送到 githubgit 命令.

You can try adding a Command Line Script task to the agent job of the build pipeline, and then push the update to github via the git command.

任务中添加的命令如下:

The commands added in the task are as follows:

    git clone https://github.com/XXX/XXX.git
    git config --global user.name "XXX"
    git checkout master
    git add .
    git commit -m "abc"
    git push https://%gt%@github.com/xxx/xxx.git

这是我的示例:

注意:您需要在推送 url 中提供您的 github PAT,如下例所示:

Note:You need provide your github PAT in push url, like the example below:

git push https://{yourPAT}@github.com/xxx/yyy.git

为了保护您的 PAT,您可以使用安全变量,例如 gitHubPat,将变量类型更改为秘密.

To protect your PAT, you could use secure variable , such as gitHubPat, change variable type to secret.

然后你可以添加一个环境变量,在我的例子中:gt.然后将其值设置为 $(gitHubPat).在命令行任务中,您使用 double %% 来获取环境变量gt"的值.

Then you could add an Environment Variable, in my example: gt. Then set its value to $(gitHubPat).In command line task, you use double %% to get the value of environment variable "gt".

如果您需要将更新从 azure devops repo 实时推送到 github repo,您​​可以在 Build Triggers 中设置并选中 启用持续集成 选项.所以如果你的主分支发生变化,它会触发 ci build,你的更新将被推送到 github repo.

If you need to push the updates from your azure devops repo to github repo in real time, you can set in Build Triggers and check the Enable continuous integration option.So if your master branch changes, it will trigger ci build, your update will be pushed to github repo.

希望这会有所帮助.

这篇关于将更新从 azure 推送到 github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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