0

I'm trying to automate the tagging of the repositories of my project. The code is hosted on a private BitBucket, and Continuous Integration is automated on Bamboo which runs only on a Windows 10 agent (at the moment). The agent has MINGW Git capabilities as well as the PowerShell, but from Bamboo I can only setup command line tasks on either cmd.exe or Windows PowerShell.

I have set up a specific user on BitBucket with write permissions on the repository, with a known password. The user authenticates on BitBucket via SSH:

remote.origin.url=ssh://git@git.mycompany.com:7999/myproject/myrepository.git

The origin.url variable is set directly from Bamboo variables, so no simple way to switch to a https://username:password@git.mycompany.com... url to manually specify the password.

Without doing anything more than setting the local user.name and user.password to the proper values, the git push --tags command fails:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

So I guessed the proper way to grant the user access rights was to use SSH authentication method. However, it seems the Git instance in PowerShell is not aware of pageant: after importing the ssh key via Git Bash the command still fails on PowerShell, but is successful in Git Bash. At this point, I'm stuck since it seems there's no way to either let PowerShell be aware of my id_rsa files, either .pub or .ppk, and attempts to call Git Bash from PowerShell to make the other executable do the dirty work have failed:

"C:\Program Files\Git\git-bash.exe git push --tags --set-upstream origin test-tag-branch"
"C:\Program Files\Git\bin\git.exe push --tags --set-upstream origin test-tag-branch"
"C:\Program Files\Git\bin\git" "push --tags --set-upstream origin test-tag-branch"
"C:\Program Files\Git\bin\bash.exe git push --tags --set-upstream origin test-tag-branch"

Also, it's important to mention that while the push above is just one, the actual behaviour would be to compute a tag from the build number and push the tag on various repositories: since it's a proper script instead of a single command, adding MinGW as an executable to the Bamboo agent capabilities and running a "executable" job with the push parameters is not going to work (unless MinGW shell itself is able to process unix-like scripts).

Did anyone successfully setup a similar automation? What am I doing wrong? Suggestions to tackle the problem from a different perspective?

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.