Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi,
I am using git (at bitbucket) as a source code repository. Since I could not make the git jenkins plugin run, I have set up a shell skript (on Linux Ubuntu) that checks out my source code from git.
At the moment, I am running this job every day, but I was wondering, if it is possible to connect the git repository to the jenkins task, as some kind of hookup.
So every time, I change something on the source files, the build will be triggered to run.
This is interesting for older projects, where are not so many changes and therefore I don't need to run a build on a daily base.
Thanks in advance and please excuse my english. It 's not my mother language.
Best regards,
Alexander Spetko
Community moderators have prevented the ability to post new answers.
OK. I'm getting close. The error message was not clear. I've fixed the git executable directory path and now the new message is
Failed to connect to repository : Command "/usr/local/git/bin/git ls-remote -h git@bitbucket.org:myname/myproject.git HEAD" returned status code 128: stdout: stderr: Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
Hi Claudio,
when connecting to Bitbucket from jenkins repo
the actual url given by bit bucket is "ssh://git@bitbucket.org:dinesh_arumugam/vsci.git"
the above url will give the beow error:
Failed to connect to repository : Command "git ls-remote -h ssh://git@bitbucket.org:your_name/vsci.git HEAD" returned status code 128:
stdout:
stderr: ssh: Could not resolve hostname bitbucket.org:dinesh_arumugam: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
To solve the above error just change the bitbucket repo link to
ssh://git@bitbucket.org/your_name/vsci.git
by just replacing the ':' in to slash '/' before your name
to configure it in jenkins jobs in the GIT repo option.
then try to run the run the below command in your terminal
"git ls-remote -h ssh://git@bitbucket.org/your_name/vsci.git HEAD"
just replace the ':' into a slash '/'
once the command is run you will get it working in the jenkins tool
and your ssh will be generated.
regards,
Dinesh Arumugam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Im facing similar issue. But when I ran the "git ls-remote -h ssh://git@bitbucket.org/your_name/vsci.git HEAD" command, it doesn't return anything. No error, nothing.. Can you pls help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure THAT is the problem cos I've changed the permissions for the the project directory with
chmod 777 MyProjectAdHocBuild
but still....nothing....
at hudson.model.Executor.run(Executor.java:236)
Caused by: hudson.plugins.git.GitException: Command "/usr/local/git/bin/git clone --progress -o origin git@bitbucket.org:myname/myproject.git /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace" returned status code 128:
stdout: Cloning into '/Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace'...
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I resolved connecting Bitbucket and Jenkins by following the steps below:
I created a private and public key using ssh-keygen.
In Bitbucket
Save your public Key in your Bitbucket Account under https://bitbucket.org/YOURUSERNAME/test/admin/access-keys/
In Jenkins
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am completely new to Bitbucket and we have migrated from SVN, i am looking for detailed steps of integrating Bitbucket and jenkins for build setup, is there any detailed documentation available?
Can you please help in setting this process?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK,fixed it. I was entering the branch name in the configuration area in lower case and that field is case sensitive. Pretty stupid error,but nasty.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok maybe I found the solution here: http://colonelpanic.net/2011/06/jenkins-on-mac-os-x-git-w-ssh-public-key/
My problem now is different
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace - hudson.remoting.LocalChannel@25f3b536
Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from git@bitbucket.org:myuser/myproject.git
No candidate revisions
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Archiving artifacts
Finished: FAILURE
At least I found how to check it out
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe this can be useful:
MacMini:~ myuser$ cat /Library/LaunchDaemons/
com.logmein.logmeinserver.plist com.microsoft.office.licensing.helper.plist org.jenkins-ci.plist
MacMini:~ myuser$ cat /Library/LaunchDaemons/org.jenkins-ci.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StandardOutPath</key>
<string>/var/log/jenkins/jenkins.log</string>
<key>StandardErrorPath</key>
<string>/var/log/jenkins/jenkins.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>JENKINS_HOME</key>
<string>/Users/Shared/Jenkins/Home</string>
</dict>
<key>GroupName</key>
<string>daemon</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.jenkins-ci</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>jenkins</string>
<key>SessionCreate</key>
<true />
</dict>
</plist>
MacMini:~ myuser$
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the output:
Jenkins:~ vejenkins$ ps axu | grep "/jenkins"
vejenkins 11660 0.0 4.6 2918124 97096 ?? S 6:59pm 1:05.63 /usr/bin/java -jar /Users/vejenkins/Library/Caches/org.jenkins-ci.jenkins/jenkins.war
jenkins 9896 0.0 9.0 2939824 188552 ?? Ss 4:06pm 17:55.91 /usr/bin/java -jar /Applications/Jenkins/jenkins.war
vejenkins 11930 0.0 0.0 2432768 588 s000 S+ 10:28am 0:00.00 grep /jenkins
Jenkins:~ vejenkins$ ps axu | grep tomcat
vejenkins 11932 0.0 0.0 2432768 588 s000 S+ 10:28am 0:00.00 grep tomcat
Jenkins:~ vejenkins$
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
vejenkins is my user but it looks like the java process is running under another user called jenkins
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what user do you use to start the tomcat jenkins is running in and how do you start tomcat?
running
ps axu | grep tomcat
should show what user the tomcat is running under
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the solution is here:
http://stackoverflow.com/questions/12097982/jenkins-finds-cannot-find-ssh-key
but I cannot find a way to implement all this command on the Macosx console....
It's definitely an user permission problem....any idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
found something here: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
but how to find the user Jenkinds is running as? that tomcat6 referenced in the documentation is definitely wrong
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I have done but still error. I think the problem are in the permission for git. In the error log the command which is failing is
/usr/local/git/bin/git clone --progress -o origin git@bitbucket.org:myname/myproject.git/Users/Shared/Jenkins/Home/jobs/MyProjectAdHocBuild/workspace
If I try to run it in the console I get this:
fatal: could not create work tree dir '/Users/Shared/Jenkins/Home/jobs/MyProjectAdHocBuild/workspace'.: Permission denied
so if I run it in SUDO mode it works.
How can I give to Jenkings the permission to run git in Admin mode?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you tried restarting jenkins after adding the host do the authorized hosts?
is the jenkins running under the same user?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you call
git clone git@bitbucket.org:myname/myproject.git
from the command line?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes it's working
Jenkins:~ vejenkins$ git clone git@bitbucket.org:myname/myproject.git
Cloning into 'myproject'...
remote: Counting objects: 5494, done.
remote: Compressing objects: 100% (4113/4113), done.
Receiving objects: 19% (1071/5494), 13.12 MiB | 529 KiB/s
also if I run:
/usr/local/git/bin/git ls-remote -h git@bitbucket.org:myname/myproject.git HEAD
it doesn't give any error message. It looks like Jenkings cannot run the command
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use git@bitbucket.org:myname/myproject.git as repository URL (without the ssh://)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok I've done it
Jenkins:~ vejenkins$ ssh git@bitbucket.org
PTY allocation request failed on channel 0
conq: logged in as myname
You can use git or hg to connect to Bitbucket. Shell access is disabled.
Connection to bitbucket.org closed.
but it keeps on failing. In the URL config are I've provided it as ssh://git@bitbucket.org:myname/myproject.git
but the error is
stderr: ssh: Could not resolve hostname bitbucket.org:myname: nodename nor servname provided, or not known
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Done. Back to the other error
Failed to connect to repository : Command "/usr/local/git/bin/git ls-remote -h git@bitbucket.org:myname/myproject.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I really don't know how to fix it....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Host key verification failed
you need to make sure that the host key is in the allowed hosts. Simple do this by running the command
ssh git@bitbucket.org
and answer the question that asks to add the host with yes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use the url that is shown on the bitbucket repository front page, something like
git@bitbucket.org:blindjustis/public.git
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
so..what I've done:
ssh-keygen -t rsa
pbcopy < /Users/jenkins/.ssh/id_rsa.pub
and I added this SSH key to my BitBucket profile.
but in the configuration area,when I use /https://myname@bitbucket.org/myname/myproject.git
I get the error: Failed to connect to repository : Error performing command: git ls-remote -h https://...</span<>>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to create a ssh key by running ssh-keygen, this creates a id_rsa and a id_rsa.pub file in the directory ~/.ssh
then you have to add the content of the id_rsa.pub file to the bitbucket repository und deployment keys
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
Recommended Learning For You
Level up your skills with Atlassian learning
Learning Path
Apply agile practices
Transform how you manage your work with agile practices, including kanban and scrum frameworks.
Learning Path
Configure agile boards for Jira projects
Learn how to create and configure agile Jira boards so you can plan, prioritize, and estimate upcoming work.
Jira Essentials with Agile Mindset
Suitable for beginners, this live instructor-led full-day course will set up your whole team to understand how to use Jira with an agile methodology.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.