gerrit(version:3.4.1), execute (ssh -p 29418 username#xx.xx.xx.xx gerrit gsql), return(fatal: gerrit: gsql: not found) - h2

Our gerrit version is 3.4.1, when i execute ssh -p 29418 username#xx.xx.xx.xx gerrit gsql, it return fatal: gerrit: gsql: not found.
And when i execute ssh -p 29418 usename#xx.xx.xx.xx gerrit --help, there is no gsql cmd in the returned gerrit instructions list.
How can i operate gerrit database?

Gerrit 3.0 onwards has removed the use of an external database in favor of the git based noteDb and gsql has been removed

As of version 3.x, Gerrit switched the internal database to NotesDB.
You can directly use git to access the notes (which represent the dabase content). For example, to query a change, you could
$ git init
$ git fetch https://gerrit.googlesource.com/gerrit refs/changes/40/329240/meta
$ git log -p FETCH_HEAD
(Example adopted from the NotesDb backend documentation page, where you can find more information as well.)

Related

what are the steps to push changes to git from teamcity using windows agent

need steps to git push one file to specific branch in git
git add -f %FileToCommit%
git commit -m "Adding file via build "
git push --force origin
but this code giving Host key verification failed. error
Under the account running those command (TeamCity is I believe your previous question), runs:
ssh git#github.com
And type 'yes' when SSH asks for accepting the Host.
Then try again, and it should not give you "Host key verification" error anymore.

Continuous Integration With Gerrit and Xcode Server

I am trying to run Continuous Integration for iOS with an Xcode server running validation tests against Gerrit.
In order to get Xcode to pull from the gerrit server I had to upgrade it's libgit2.dylib to version 0.21.5
I downloaded it from https://codeload.github.com/libgit2/libgit2/zip/v0.21.5
Anyone have suggestion on how to get gerrit to trigger Xcode builds of particular branches?
An easy way is to create an Xcode bot that will perform the build. You can have the bot set to poll Gerrit’s repository periodically for the desired hook (most likely ‘commit’).
http://bjmiller.me/post/72937258798/continuous-integration-with-xcode-5-xctest-os-x is a good step-by-step guide on setting up an Xcode bot, but keep in mind that you are using Gerrit as the git repository.
With an Xcode bot created, you could also create a Gerrit hook that triggers a build in the same manner that an Xcode git repository would: Custom Trigger Scripts for Bot (Xcode 5 CI)
The whole thing is complicated but...
Set up a Jenkins jobs that is triggered by Gerrit (My entire goal is to bring iOS tools to parity with Android)
When that job runs it performs the following shell script. This can be improved by polling the server first and parsing out the BOT_HASH but I just did it by hand. The bot is set to integrate manually.
curl -kg -X POST "https://[XCODE_SERVER]:20343/api/bots/[BOT_HASH]/integrations/"
The bot has the following script as a pre-integration step
cd [PROJECT]
ssh -p 29418 xcode#[GERRIT_SERVER] 'gerrit query label:Verified=0 project:[PROJECT] status: open limit:1 --current-patch-set' >/tmp/junk.txt
export commit=`grep revision: /tmp/junk.txt | grep -oE '[^ ]+$'`
export ref=`grep ref: /tmp/junk.txt | grep -oE '[^ ]+$'`
git fetch "http://[GERRIT_SERVER]:8081/[PROJECT]" $ref && git checkout FETCH_HEAD
git checkout -b $commit
ssh -p 29418 xcode#[GERRIT_SERVER] 'gerrit review -p [PROJECT] -m "Starting Test" '$commit
This checks the gerrit server for the most recent update to the project that hasn't been verified. It might not get the right one, but eventually they will all be be checked. It then updates the git repository to no longer point to the commit at the head but at the one we want to check. Finally it posts a comment for users so they know it is being looked at.
This relies on a user Xcode existing on the gerrit repo with proper auth's. You can inline usernames and passwords, or you can set up the ssh key from _xcsbuildd.
The success script looks like
export commit=`grep revision: /tmp/junk.txt | grep -oE '[^ ]+$'`
ssh -p 29418 xcode#[GERRIT_SERVER] 'gerrit review -p [PROJECT] -m "Test from the script xcbot://[XCODE_SERVER]/botID/'$XCS_BOT_ID'/integrationID/'$XCS_INTEGRATION_TINY_ID'" --verified +1 '$commit
This marks it as verified and posts a link that leads directly to the integration. The link is clickable in email but not on the webpage.
The failure looks like this
export commit=`grep revision: /tmp/junk.txt | grep -oE '[^ ]+$'`
ssh -p 29418 xcode#[GERRIT_SERVER] 'gerrit review -p [PROJECT] -m "Test from the script xcbot://[XCODE_SERVER]/botID/'$XCS_BOT_ID'/integrationID/'$XCS_INTEGRATION_TINY_ID'" --verified -1 '$commit
It is up to you what you consider success or failure. Currently I succeed on warnings and success and fail on build errors and test failures.
To get it to recheck, remove the vote and manually trigger the bot.

Gerrit Prolog Rules: Getting started

I would like to alter the commit rules for gerrit but somehow I am seemingly unable to follow the steps described in the cookbook (for example here:
http://saros-build.imp.fu-berlin.de/gerrit/Documentation/prolog-cookbook.html#_the_rules_pl_file )
On my local gerrit system I simply created an empty project
ssh user#localhost -p 29418 gerrit create-project --empty-commit --name demo-project
Next I cloned the new project
git clone ssh://user#localhost:29418/demo-project
Then according to the description I tried
/demo-projectmaster% git fetch origin refs/meta/config:config
which resulted in
fatal: Couldn't find remote ref refs/meta/config
Could you tell me what I am doing wrong? Feels like something very basic...
Thanks,
JS
it was due to missing access criteria.
I had to (in gerrit) grant the user explicit Read/Submit rights on refs/meta/config despite the user being in the administrator group.
Jörg

Gitolite hook doesn't work

I've set a GIT server on Windows with Cygwin and gitolite as it's described in the article.
On a client Windows machine I use TortoiseGit.
Right after the setup everything works ok. I can clone gitolite-admin repository with TortoiseGit using my SSH key and see the repository content.
But right after I try to push a new content of /conf/gitolite.conf the server is not accessible anymore using my SSH key (it's removed from *authorised_keys* on the server by gitolite).
The new content of gitolite.conf (I would like to add new repository Project):
repo gitolite-admin
RW+ = alexey
repo Project
RW+ = alexey
repo testing
RW+ = #all
What's wrong with it?
The problem was in sshd service environment. See this link for details.
To fix the problem reinstall the service with proper PATH variable setting. To do this on Windows Server 2008 use:
cygrunsrv -R sshd
cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd -a "-D" -y tcpip -u cyg_server -w {cyg_server_password} --env "PATH=/usr/local/bin:/usr/bin:/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem"
cygrunsrv -S sshd
If you don't remember cyg_server account password you can rerun ssh-host-config.
To restore access for your public key use:
gl-setup ~/YourKey.pub
After these you can access and modify your gitolite-admin repository remotely.

Hosting Git Repository in Windows

Is there currently a way to host a shared Git repository in Windows? I understand that you can configure the Git service in Linux with:
git daemon
Is there a native Windows option, short of sharing folders, to host a Git service?
EDIT:
I am currently using the cygwin install of git to store and work with git repositories in Windows, but I would like to take the next step of hosting a repository with a service that can provide access to others.
Here are some steps you can follow to get the git daemon running under Windows:
(Prerequisites: A default Cygwin installation and a git client that supports git daemon)
Step 1: Open a bash shell
Step 2: In the directory /cygdrive/c/cygwin64/usr/local/bin/, create a file named "gitd" with the following content:
#!/bin/bash
/usr/bin/git daemon --reuseaddr --base-path=/git --export-all --verbose --enable=receive-pack
Step 3: Run the following cygrunsrv command from an elevated prompt (i.e. as admin) to install the script as a service (Note: assumes Cygwin is installed at C:\cygwin64):
cygrunsrv --install gitd \
--path c:/cygwin64/bin/bash.exe \
--args c:/cygwin64/usr/local/bin/gitd \
--desc "Git Daemon" \
--neverexits \
--shutdown
Step 4: Run the following command to start the service:
cygrunsrv --start gitd
You are done. If you want to test it, here is a quick and dirty script that shows that you can push over the git protocol to your local machine:
#!/bin/bash
echo "Creating main git repo ..."
mkdir -p /git/testapp.git
cd /git/testapp.git
git init --bare
touch git-daemon-export-ok
echo "Creating local repo ..."
cd
mkdir testapp
cd testapp
git init
echo "Creating test file ..."
touch testfile
git add -A
git commit -m 'Test message'
echo "Pushing master to main repo ..."
git push git://localhost/testapp.git master
GitStack might be your best choice. It is currently free (for up to 2 users) and open source at the time of writing.
Here's a dedicated git server for windows: https://github.com/jakubgarfield/Bonobo-Git-Server/wiki
If you are working in a Windows environment, have you considered Mercurial? It is a distributed version control system like Git, but integrates far more neatly and easily with Windows.
Installing CygWin is an overkill, read this tutorial on how to do it faster and native:
http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
If you get the error cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062: The service has not been started. after running the command:
cygrunsrv --start gitd
that means that you did not create the 'base-path' folder.
Creating the folder '/git' and rerunning the command will fix this.
I'm currently using cygwin's ssh daemon on Windows to serve up and allow remote access to my repo. It works quite well, I have complete control over who accesses my repo by their ssh certificates, and the performance blazes, even over remote WAN and VPN links.
Another solution is to use Gitosis. It is a tool that makes hosting repos much easier.
You do not need to host a service, you can also create a shared repository on a shared drive. Just create a bare repository. You can clone an existing repo into a shared one using: "git clone --bare --shared [source] [dest]". You can also init a new repository using "git init --bare --shared=all".
Henk
Have you considered using the cygwin layer? See this link.
Now msysGit supports git daemon ! It works fine (for me at least). I gonna try to make it run as service...
SCM Manager
Lightweight http-server for Git, Mercurial, Subversion repos from a box (only Java is needed)
Web-interface for management of users, ACLs, repos
On Windows, you can also serve Git repositories with Apache over HTTP or HTTPS, using the DAV extension.
The Git repository path can then be protected with Apache authentication checks such as restricting to certain IP addresses or htpasswd/htdigest type authentication.
The limitation of using htpasswd/htdigest authentication is that the username:password is passed in the requested Git URL, so restricting access to the Git URL to certain IP addresses is better.
Edit: Note, you can leave the password out of the Git URL and Git will prompt you for the password on push and fetch/pull instead.
Using HTTPS means all the data is encrypted in transfer.
It's easy enough to set up, and works.
The following example shows the combination of access control by IP address and user:password over standard HTTP.
Example Apache Virtualhost
## GIT HTTP DAV ##
<VirtualHost *:80>
ServerName git.example.com
DocumentRoot C:\webroot\htdocs\restricted\git
ErrorLog C:\webroot\apache\logs\error-git-webdav.log
<Location />
DAV on
# Restrict Access
AuthType Basic
AuthName "Restricted Area"
AuthUserFile "C:\webroot\apache\conf\git-htpasswd"
# To valid user
Require valid-user
# AND valid IP address
Order Deny,Allow
Deny from all
# Example IP 1
Allow from 203.22.56.67
# Example IP 2
Allow from 202.12.33.44
# Require both authentication checks to be satisfied
Satisfy all
</Location>
</VirtualHost>
Example .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://username:password#git.example.com/codebase.git
[branch "master"]
remote = origin
merge = refs/heads/master
At work I'm using GitBlit GO installed on a Windows Server. Work flawlessly and integrate well with ActiveDirectory for user authentication and authorization. It is also free and opensource (Apache licensed)
GitBlit homepage
Only HTTP(S) access is supported, no SSH, but under Windows you shouldn't need anything more.
this is a 2015 answer to a question that is over 7 years old.
For $10 one time payment, from https://bitbucket.org/product/server, one can purchase a 64-bit Windows licence for up to 10 users.
Apparently 32-bit versions are only available via their archive.
Bitbucket Server was previously known as Stash.
Please note that i have not tried this version but $10 seems like a good deal; here i read that Atlassian gives the $10 to charity. FWIW
I think what Henk is saying is that you can create a shared repository on a drive and then copy it to some common location that both of you have access to. If there is some company server or something that you both have ssh access to, you can put the repository someplace where you can SCP it back to your own computer, and then pull from that. I did this for my self a little while, since I have two computers. It's a hassle, but it does work.
For Windows 7 x64 and Cygwin 1.7.9 I needed to use /usr/bin/gitd as the args argument of cygrunsrv
cygrunsrv --install gitd \
--path c:/cygwin/bin/bash.exe \
--args /usr/bin/gitd \
--desc "Git Daemon" \
--neverexits \
--shutdown
Also, I needed to run bash as an Administrator to install the service.

Resources