it:ad:jenkins:howto:checkout_from_a_git_repository_on_bitbucket

IT:AD:Jenkins:HowTo:Checkout from a Git Repository on BitBucket

Create a new Project

Select Git as the VC source, and enter the Git Repository Url that BitBucket gave. For example:

  • SSH: git@bitbucket.org:xact/gittest.git
  • HTTPS: https://xact@bitbucket.org/xact/gittest.git
Using HTTPS Protocol

https://xact@bitbucket.org/xact/gittest.git

Moving right along to the SSH protocol.

Using SSH Protocol
git@bitbucket.org/xact/gittest.git

Result:

Failed to connect to repository : Command "C:\Program Files (x86)\Git\bin\git.exe ls-remote -h git@bitbucket.org/xact/gittest.git HEAD" returned status code 128: stdout: stderr: fatal: 'git@bitbucket.org/xact/gittest.git' does not appear to be a git repository fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists`

Reasons:

  • The git syntax uses a ':' after the org – not a '/'
ssh://git@bitbucket.org:xact/gittest.git

Result:

Failed to connect to repository : Command "C:\Program Files (x86)\Git\bin\git.exe ls-remote -h ssh://git@bitbucket.org:xact/gittest.git HEAD" returned status code 128: stdout: stderr: ssh: bitbucket.org:xact: no address associated with name fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Reason:

  • The ssh:// syntax uses a '/' after org – not a ':'

#

##### ssh:git@bitbucket.org/xact/gittest.git Result: >502 - Web server received an invalid response while acting as a gateway or proxy server. Reason: * Correct syntax, so…? * Ah. Yes. I had remembered to create the HOME environment value for the service account – but it needed a restart of the service to take effect, and from there Git starts working better. * See: http://skysigal.com/doku.php?id=IT:jenkins_howto_install ###### git@bitbucket.org:xact/gittest.git Result: >502 - Web server received an invalid response while acting as a gateway or proxy server. Reasons: * Correct syntax, so…? ##### Resolution 0. The urls are case sensitive and lowercase (the target is a linux server after all). 0. Ensure that the Git Plugin's url is hard set to use the %programfiles(x86)%\git\cmd\git.exe rather than %programfiles(x86)%\git\bin\git.exe 0. Copy the .ssh folder to %programfiles(x86)%\git\cmd so it can find it. 0. Verified. Not required as long as there is a .ssh folder in the %programfiles(x86)%\git\bin\ folder. 0. Verified. Not required in the %programfiles(x86)%\git\bin\ either. 0. Not sure what's going on… Getting it from %HOME% ? 0. Verified – yes: there is a copy of the .ssh folder in the LocalSystem %HOME% folder. 0. Seems both are important: 0. using the cmd version of Git. 0. a copy of the .ssh folder in the LocalSystem %HOME% folder. 0. consider restarting the jenkins service to let the %HOME% environment variable “take”. ### Ensure Git it Configured. The first time you check out and build, you'll maybe see: <sxh> FATAL: Could not apply tag jenkins-GitTest-1 hudson.plugins.git.GitException: Could not apply tag jenkins-GitTest-1 …. Caused by: hudson.plugins.git.GitException: Command “C:\Program Files (x86)\Git\cmd\git.exe tag -a -f -m Jenkins Build #1 jenkins-GitTest-1” returned status code 128: stdout: stderr: *** 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 'SYSTEM@XActVNS00.(none)') </sxh> Says exactly what you have to run from the command prompt. <sxh> git config –global user.email “you@example.com” git config –global user.name “Your Name” </sxh> It will create/udpate %userprofile%\.gitconfig file with: <sxh> [user] email = ci@xact-solutions.com name = XAct CI </sxh> Awesome. Except that from the command prompt on the server, you're not the same account that the service is running under… So you have to copy the above .gitconfig file to the %HOME% account of the Service running your CI environment. The default service account for Jenkins is LocalSystem/ (which is bad…you should change it) whose profile is stored under c:\Windows\SysWOW64\config\systemprofile. Move your .gitconfig file there. Try again. This time, you should get: <sxh> Build succeeded. </sxh> Woohoo. ## Resources ## * https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin * http://computercamp.cdwilson.us/jenkins-git-clone-via-ssh-on-windows-7-x64 * mentions copying .ssh under git…

  • /home/skysigal/public_html/data/pages/it/ad/jenkins/howto/checkout_from_a_git_repository_on_bitbucket.txt
  • Last modified: 2023/11/04 01:46
  • by 127.0.0.1