Home > Net >  Push git current branch to a remote git in Azure Pipeline
Push git current branch to a remote git in Azure Pipeline

Time:11-26

Using old fashion way in Azure Dev Ops to create pipeline, I'm looking for a solution to push the git current branch to a remote git. This is really not conventional I know, but if it's done automatically, I have to do it manually and I'm not good to remember things. Moreover, I like to resolve new challenge.

Here is what I have currently: enter image description here

And the script executed is:

git remote add EXT [email protected]:v3/EXT/EXT-Project/ext-web-app
git fetch
git push origin HEAD:master --force
git branch -f develop origin/develop
git pull EXT develop

What I noticed is when the Command Line task starts:

  • the git is currently on a detached branch
  • so I force to go to the local develop branch (the branch I want to copy to EXT remot git)
  • then I try to pull the current branch (develop) to the external Git

Question:

  • How to set up the credentials of the external git (EXT)?
  • How to finish the script to synch the current git branch to the external git branch?

Note: I don't need to handle the merge conflict with the external git branch, if it happens, the pipeline failed and that's it (it's not supposed to happen btw)

CodePudding user response:

You could use the Install SSH Key task, as seen in "Checkout git submodule in Azure Pipeline with SSH", in order to force the pipeline to use your private/public key.

Make sure you have the right to access the EXT/EXT-Project, meaning the public key which will authenticate you must refer to an account authorized to read EXT/EXT-Project.

  • Related