How to sync Azure Devops Repo with Gitlab

久未见 提交于 2021-01-29 09:56:07

问题


We are using Azure Devops repo for some of our development needs. We are also using gitlab as our main source control. I want to keep my gitlab repo in sync with Azure repo. That is whenever some change is committed in Azure Repo, it should automatically flow to Gitlab. We are using GitLab CE, hence mirroring Pull option is not available


回答1:


I think you can try to use Command Line Script task in build pipeline, and then push the update to gitlab via the git command as follow shown.

git clone https://gitlab.com/{account name}/{project name}.git
git config --global user.name "XXX"
git checkout master
git add .
git commit -m "abc"
git push https://%pt%@gitlab.com/xxx/xxx.git

At first, I restore the value of gitlab token in to the variable, for example GitlabPAT and set it as secret. And then add an environment variable: pt, set this environment variable value to $(GitlabPAT).

In command line task, use double %% to get the value of environment variable pt.

In addition, for pushing the commits from the azure devops repo to gitlab repo in real time, you can set the Build Triggers as Enable continuous integration option.So once the master branch changes, it will trigger CI build, and also your update will be pushed to gitlab repo with these git commands.



来源:https://stackoverflow.com/questions/57359245/how-to-sync-azure-devops-repo-with-gitlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!