简体   繁体   中英

How can I do git rebase and push to remote branch from teamcity agent using commandline

I want to do the following via command line script in teamcity build configuration step:

git rebase master
git push origin <branchname>:<remotebranchname>

In this case, it does not create a specific branch on teamcity agent so not sure, what should be branch name. But just running

git push 

throws following exception:

*** Please tell me who you are. Run

git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@teamcity-xxxxxx(none)')

Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Process exited with code 128 Process exited with code 128 (Step: Command Line) Step Command Line failed

Git push wasn't working because it needed the sshkey associated with Git. In the above example, I was struggling because I didn't have a way to associate the key for it push command to work.

In teamcity there is a build feature called "SSH Agent" and select the sshkey which you want to associate for push commands. After adding that, the git push command started working.

This feature is available, in build configuration -> Build Feature -> Add Build Feature -> Select "SSH Agent" and select the uploaded key. This is something which is already uploaded in teamcity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM