I been trying to fix this for a couple of days but no succsses yet, hope you can help me out:
What I have to do is to daily clone specific branchs of the company's git repo to specific (windows) vm's on the server.
For learning matters, right now im just trying to clone the master branch in a folder on my Desktop.
Two important observations:
1 - I know that git is installed on the puppet agent
2 - The repository doesnt have passphrase and the private key (ssh) is well allocated on the windows agent.
Now the code i have:
vcsrepo{ "C:\{Name of the win agent user}\Desktop\folder":
ensure => present,
provider => git,
source =>'git#scm.example.com.br:controle_versoes.git',
}
When I run windows agent I receive the following message:
Error: /Stage[main]/Main/Node[{nameoftheagent}]/Vcsrepo[C:\User{Name
of the win agent user}\Desktop\folder]: Provider git is not
functional on this host
Any idea what the problem is or how could i fix it?
Thank you a lot!
Gustavo B. Barbosa
The error ("Provider git is not functional on this host") generally means that Puppet is unable to find the git command. If git is installed, that probably means that the command is not in a directory that is in your PATH environment variable.
Related
I installed Git for Windows in order to clone and pull a project hosted on a remote Linux server.
In my repository (D:/repositories/my-project) I launch the following commands
git clone server#192.168.56.101:/var/www/web/my-project/.git
git pull origin master
So far so good. I pull the project files whenever modifications are applied on the server.
But now I'd like to pull or push from the remote server to my local repository.
I tried many things but I can't figure out how to access the repository located on my local machine.
Things like:
git pull duddy#my-pc:/d/repositories/my-project/.git master
just doesn't work, Git says:
ssh: Could not resolve hostname my-pc: Name or service not known
fatal: Could not read from remote repository.
Can someone helps me ?
First things first, I would recommend you try simply running git pull.
If this doesn't work, try running git remote -v and check to make sure that the URL for your server is listed as an origin (server#192.168.56.101:/var/www/web/my-project/.git).
Your issue is that you are inputting the URL for your local repository in your attempt to git pull.
I suggest reading the git-pull documentation to learn more about how pull works.
Basically, you need to have some service at your workstation which serves the requests. There are following options (I did not try most of them myself, just making it up from what I know):
use the windows file access. This is the easiest to setup at the windows workstation - just share the repository folder. The Linux side should somehow be able to mount windows shares (like described, for example, here: https://wiki.ubuntu.com/MountWindowsSharesPermanently). If you manage to mount your \\my-pc\repo to some /mount/my-pc-repo, then you can access it as file:///mount/my-pc-repo.
run git daemon at windows. Set up instructions are available at SO (for example, https://stackoverflow.com/a/2275844/2303202) and it pretty straightforward, but it does not have any authentication and in most cases it is reasonable to use it only for reading, so you will not be able to push to the workstation, only fetch.
set up ssh daemon and access through ssh authentication with read-write access. Git for windows installation contains the needed software (the sshd.exe binary, it is there at least for Git for Windows 2.6.0), probably there is a way to utilize it but I could not find it quickly.
set up HTTP(S) service at your workstation. I don't know if it is possible to do only with Git for Windows (it might be, with some perl module which happen to be included with it), or you should use some other software.
I need some help here, It's been a week I'm with this problem, can't figure out what's going on. I'm not able to clone a git repo from a slave node (Jenkins). I added the ssh key, host and slave (I've already tried generating a single key and one for each virtual and host)).
On Jenkins:
url:git#github.com: < repo>
Credentials: Here I tried with username/password, username with ssh file, username with ssh key directly, and -none-.
It doesn't seems like there is an authentication problem since I can clone the repo manually from console (both, slave and host). I can also connect with
ssh -T git#github.com
so the ssh key is fine, but when I build, this appear on console:
Building remotely on IE10Win7 in workspace C:\Users\IEUser\Desktop\<
folder >
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository git#github.com:< repo>.git
git init C:\Users\IEUser\Desktop\< folder> # timeout=10
ERROR: Error cloning remote repo 'origin'
ERROR: Error cloning remote repo 'origin'
Performing Post build task...
Does anyone have an idea? Hope someone can give me a clue, Thanks!
I fixed this problem by setting the slave node tool path, selecting git and setting its value to
C:\Program Files (x86)\Git\bin\git.exe
Location: Configure Node - Tool Locations
I recently updated several jenkins plugins and had this problem after the updates. Rolling back the git plugin didn't help, but I did a few other things to get it working. I listed all three here, but it was probably (2) that fixed the problem. Apparently the git executable was reset to default. So, configuring the git executable within the specific project was probably all that was needed. However the other items might come in handy too.
(1) The default git on a jenkins linux install geenrally points to /usr/lib... You need to specify a separate GitForWindows that points to the windows version:
Manage Jenkins
Configure System
Under Git - Git Installations
Add Git -> Git
Give it a name to be referenced in projects
(mine is WindowsGit)
Set Path to Git Executable
(mine is "C:\Program Files (x86)\Git\bin\git.exe")
(for recent git the path is "C:\Program Files\Git\bin\git.exe")
(2) Configure git on the specific project:
Select the project
Select Configure
Under Source Code Management - Git
Select Git Executable as configured in 1)
Set credentials or add new (ssh keys, etc)
(3) Updating the jenkins slave service to run as a specific user:
Go to Windows Services on the slave -- StartMenu, type "services"
Select the Jenkins Slave service in the list on the right
Right-click and select "Properties" of the Jenkins Slave service
Select the "Log On" tab
Update the username and password used in manual tests
Domain login can be specificied with <DOMAIN>\<USERNAME>
Local logins just use <USERNAME>
OK to save and exit
Right-click again and select "Restart" to make the changes active.
I found a decent workaround in my case. The git clone command always inherits its process owner, which may make a difference, even if the two owners of Jenkins (SYSTEM) and cmd (USER) seem to have the same rights on your system. All other configurations were identical (keys, knownhosts, Git client version).
So as far as I can see, calling git clone from cmd will succeed because it calls the remote as USER, whereas git clone called from Jenkins may be rejected because it calls the remote as SYSTEM. In Services, where you would typically start Jenkins through the GUI, you can configure the service to run as a different user (right click on service --> Properties --> Log On). I had to put it like USER#DOMAIN, e.g. Jenkins#company.local or so. I'm not sure about how a cmd parameter would look, but I'd expect there to be one.
Also, I don't quite know what difference this workaround makes in the end, because on my Jenkins, SYSTEM and USER are configured to have the same rights across the system and they are of course both recognized as "Jenkins" by remote. Still, it does the trick for me. Deeper insights welcome.
I was facing similar problem and found that I need to add git to my PATH environment variable for a Windows based slave. I think that #dhj suggestion 2 might work as well in this case.
I found this workaround on Jenkins Jira.
In my case, I started getting this exact error after updating Git on some of my build machines (via Chocolatey, using the "git.install" package) from 1.9.4 to 2.5.0. The old 1.9.4 install was a 32-bit package but the new one is a 64-bit one, so the default install location switched from C:\Program Files (x86)\Git to C:\Program Files\Git. I had the 64-bit path configured on the Jenkins master (since it had the newer Git version), but some slaves still had the older 32-bit version installed, so the slaves were attempting to use an incorrect path. I could have overridden the Git path for individual slaves but the cleaner solution for me was simply to upgrade all the slaves to the newer 64-bit version.
I tried most of the above:
Specify git location.
Set service user.
Run as Administrator.
None of it worked. Eventually decided to uninstall git64 and install git32... changed the git path to the new location (in x86 Program Files). And everything worked.
I ran into this issue recently.
We had some items in our PATH EV which we had added when trying to connect Winium and Selenium to our Jenkins instance.
We removed these items, but still Jenkins seemed to be holding on to the values. After a bit of troubleshooting: restarting Jenkins; restarting the Jenkins server; setting the EVs at the node level; etc., we restarted the Jenkins JNLP service on the Windows slave.
And they lived happily ever after.
I also got the same error and fixed by adding a git path in the "Manage Jenkins -> Global Tool Configuration".
In my env, The windows Jenkins master run a job on the ubuntu slave machine, the master machine has used the default git ('C:\Program Files\Git\git.exe') path and the slave machine has used the git ('/usr/bin/git') path, therefore, I configured slave git path into the master configuration '/usr/bin/git' and its start working for me
i'm trying to set up a git server on Windows, but i'm having some issues getting it all to work.
I have locally created a normal repository, and remotely i created a bare repository. On the local repository i added a single text file and committed it, but when I try to push it into the remote repository I always get the following message:
fatal: protocol error: bad line length character: fata
I searched SO and other sources, and most of them suggest it's an issue regarding command echos. I'm using freeSSHd as a SSH solution (remote repository is hosted on a windows server), and I tried to use both the git bash and the windows CMD as a command shell.
I start CMD with /Q to disable echoing and /K to change directory to a directory where repositories are located, so I don't think that would be a problem.
Using the remote desktop, i can clone the repository to a folder next to it, and using the git bash locally i can access the SSH shell and also clone the repository in the same way. But using git clone ssh://<address>:/myRepo.git I always get the above message (The SSH's working folder is the same where the repository is located). Does anyone have any idea what's going on? How can I see what command is triggering the error, and how can I see the full error message?
I also met the same error using freeSSHd as a ssh solution for git server on Windows. I couldn't find a solution for a whole day and gave up. :(
Later I found another powerful ssh server from Bitvise called WinSSHD worked well. It has free version for personal use. I suggest you to switch to it. Though I'd also like to know if there's a fix to the error we both met.
To setup ssh server with WinSSHD is quite simple, and you can add virtual accounts with private/public key access.
The key part is to setup the ssh access for git server. Please follow the steps of the blog here.
It should work well for Windows git client. For Mac, you may meet an error as follows.
grp.sh: No such file or directory
fatal: Could not read from remote repository.
To fix it, you need to create the two files gup.sh and grp.sh in your git bin directory (GIT_PATH/bin or GIT_PATH/libexec/git-core configured in system environment variable PATH) in your git server.
The content of gup.sh:
git-upload-pack.exe $*
The content of grp.sh:
git-receive-pack.exe $*
I have git installed on my local windows 7 PC. I can commit there.
I have git installed on my linux dev server. I can commit there.
I have successfully cloned to each machine a github repository. So they seem to be working in that sense. But I'd like to be able to push from my PC to the dev server.
I believe that I am missing a crucial piece of info here and can't find any tutorials, questions answered on how to set this up.
I have a few questions:
I was led to believe that I don't NEED to set up ssh keys to do this, I will just be prompted for a password.
My site was developed in php, is it possible to push to the linux server and have the live dev site continue running, with the new changes?
Here is how I'm currently trying to clone from my linux server and the response... (i changed the IP address)
C:\DevEnv>git clone 0.0.0.0:gitrepo.git
Cloning into 'gitrepo'...
fatal: The remote end hung up unexpectedly
I have a directory called gitrepo.git that has a repository.
I also tried creating a repository in the home dir of mysite.com. When I try cloning that from my PC this is what happens:
C:\DevEnv>git clone http://mysite.com
Cloning into 'mysite.com'...
fatal: http://mysite.com/info/refs not valid: is this a git repository?
I've read through many tutorials and they mostly talk about either really really basic concepts, or how to push/pull to github, or just skip over certain settings so when I follow them I get fatal: The remote end hung up unexpectedly...
Any help, point in the right direction would be most appreciated!
You may need to provide your username. For example:
$ git clone myusername#myhost.com:/opt/git/project.git
Or you could setup a samba-share on the Linux box and share your git-repo, mount the share in windows and clone it from the filesystem.
More info about setting up git on a server:
http://progit.org/book/ch4-0.html
Check path to your project.
Try to clon via git protocol:
C:\DevEnv>git clone git://0.0.0.0/gitrepo.git
I have successfully cloned Git repository in Jenkins over Git/SSH on Windows 2008 32-bit. When I tried to do the same on Windows 2008 64-bit, Console Output page gets stuck here:
Démarré par l'utilisateur anonymous
Checkout:book / C:\Jenkins\workspace\book - hudson.remoting.LocalChannel#1da691a
Using strategy: Default
Last Built Revision: Revision 5d7ce4ae23c91fb201ee005e6db17bcd795ca965 (origin/HEAD, origin/master)
Checkout:book / C:\Jenkins\workspace\book - hudson.remoting.LocalChannel#1da691a
Cloning the remote Git repository
Cloning repository origin
When I stop the build (after a few minutes of being stuck there), I get the rest of the error message:
ERROR: Error cloning remote repo 'origin' : Could not clone git#github.com:zeljkofilipin/watirbook.git
ERROR: Cause: Error performing command: C:\Git\bin\git.exe clone --progress -o origin git#github.com:zeljkofilipin/watirbook.git C:\Jenkins\workspace\book
null
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1042)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:968)
at hudson.FilePath.act(FilePath.java:785)
at hudson.FilePath.act(FilePath.java:767)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:968)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:567)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:455)
at hudson.model.Run.run(Run.java:1404)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:230)
I can clone the repository via Git read-only URL git://github.com/zeljkofilipin/watirbook.git from Jenkins on both machines
I can clone via Git/SSH URL git#github.com:zeljkofilipin/watirbook.git from the command line on both machines
I can clone via Git/SSH URL from Jenkins on 32-bit machine, but not on 64-bit machine.
The only difference I can notice between the two machines (not counting that one is a virtual machine on my laptop, and another is a real machine in Switzerland) is that the first one is 32-bit and the second one is 64-bit.
Not sure if that could be related, but 32-bit machine has location set to Croatia, and 64-bit machine to Switzerland (as you can see from Git output in French).
For more information please see my blog post: Jenkins, Windows and Git
I've gone through these pains recently. Especially frustrating is the lack of error logs in this scenario: probably because MSysgit prompts user on the console when trying to recover - which doesn't get through Jenkins console.
Based on my experience here are a few key elements to watch for:
a mix of both Msysgit and Cygwin installed: MSysgit worked better for me- but I assume you're using that too
some people have more luck with <MSYSGIT_ROOT>\cmd\git.cmd than <MSYSGIT_ROOT>\bin\git.exe
making sure your slave runs as the same user (which is not the default upon service-based installs).. - oh I see you got that too
setting HOME variable for windows slaves explicity
basically make sure the same .ssh keys are reached when under Jenkins.
for debugging, I found it useful to create a test job with no SCM, but run git clone in an "Execute shell/batch" build step. That should reveal a bit more info. BTW, you can do an env in the same step and maybe ls %HOME%/.ssh
I think the above is what gave me a working a Windows 7 64bit Jenkins slave with git support - although I thought this had more to do with some other fine config detail than with 64 vs 32 bits. Good luck anyhow!
In the latest version of git, had to use %GIT_HOME%/cmd/git.exe, rather than %GIT_HOME%/bin/git.exe and figuring out the home directory of the user running the jenkins service.
Another issue i faced with was, ssh.exe was not looking at the %userprofile%/.ssh folder for the key files. Instead it was looking to the folder C:\Program Files (x86)\Git\.ssh which was empty and which causes a hang due to ssh authentication prompt on the machine where git repo located.
We just copied the key files under %userprofile%/.ssh to C:\Program Files (x86)\Git\.ssh and the problem is resolved.
Notes from a hard learned lesson.
I had problems getting the ssh to work running Jenkins as a named user account for ssh+git.
Here is what I had to do to solve the problem:
Generate the key using ssh-keygen (note where they are located)
Set "HOME" to this location
I tried with puttygen and GET_SSH=plink that all failed very bad but no clear errors.
When you have to use any configuration options from a per-user configuration file eg. ~/.ssh/config you can put them in C:\Program Files (x86)\Git\etc\ssh\ssh_config, the key files can be put in C:\Program Files (x86)\Git.ssh
If your account is attached to domain. Then you need to make sure user for which the Jenkins Slave is ran. For the purpose open Settings->Properties of "Jenkins Slave"->Log On. and choose necessary user from domain for correct execution.
Since my Windows Jenkins was a slave, I needed to configure that node to find the git in cmd instead of bin as described by inger. To do this, go to Manage Jenkins, Manage Nodes, click on the appropriate node, click on Configure and then go to the Tool Locations. Find git in the drop-down and then specify the path to git.exe (including git.exe), like C:\Program Files\Git\cmd\git.exe.
I confirmed that the cmd/git.exe worked differently than the bin/git.exe from both command-line and with a temporary jenkins job using the git command (instead of an scm repo).
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
Just add a ssh-enabled user logon to Jenkins and it should work smoothly.