问题
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?
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.
thanks for your help.
回答1:
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
Here is my sample:
Note:You need provide your github PAT in push url, like the example below:
git push https://{yourPAT}@github.com/xxx/yyy.git
To protect your PAT, you could use secure variable , such as gitHubPat, change variable type to secret.
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".
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.
Hope this helps.
来源:https://stackoverflow.com/questions/56855931/push-updates-from-azure-to-github