Posts Tagged git

Show Gitlab Version

GitLab doesn’t display an obvious version number in the admin interface. To determine your current version (useful for upgrading), open a shell:

# Navigate to your gitlab installation folder
cd /home/git/gitlab
# Run the following to show information on your enviornment
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
 
#If the above command doesn't complete, determine the version with git:
git describe --tags

, , ,

No Comments

GitLab 5+ on Ubuntu 12.04 LTS

GitLab is a neat GitHub clone that can be installed on your own servers. I wanted to setup mine running in a virtualized Ubuntu 12.04LTS environment.

These instructions are for Ubuntu 12.04.2 AMD64 and GitLab 5-3-stable

Basic Instructions are here:
https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

Deviations from Official Instructions

Ruby

Rather than downloading and compiling ruby 1.9.3, I installed it from the repo:

sudo apt-get install ruby1.9.3

However, I still installed the Bundler Gem.

MySQL

I went with MySQL over PostgreSQL simply because it integrates into my existing tools better.

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

I use MySQL Workbench to configure my server instances. Command line instructions can be found in the GitLab Docs.

Notice in the “Install Gems” step, you have to use the First option for MySQL:

sudo -u git -H bundle install --deployment --without development test postgres

, , , , ,

No Comments

Export git repository with SSH and HTTP

When I was first experimenting with GIT I was administering the server using the wbm-virtualmin-git plugin for Virtualmin. As a result, I was using the HTTP protocol to access the git repository and preform user authentication.

After struggling with the performance hit of HTTP (for some reason GIT used a lot of memory using this connection method). I decided to switch over to the SSH / public key method of accessing the repository. However, this created a new problem. It seemed that the changes pushed over the SSH connection would not be visible to any git repos who were using the HTTP address as their remote!

As it turns out, if you wish to export the repository using so-called “dumb servers” git-update-server-info must be called after each commit to update auxiliary info files. This can easily be accomplished by enabling the default post-update hook by navigating to the .git directory for the repository hosted on the server and issuing:

mv hooks/post-update.sample hooks/post-update

More information can be found in the git docs: Exporting Via Http | git-update-server-info | githooks

, ,

No Comments

Hudson (Jenkins) and Git HTTP authentication

I run a Hudson, (now Jenkins) CI server on windows XP.
The Jenkins git plugin is broken if you have repositories that use HTTP auth (See: http://issues.hudson-ci.org/browse/HUDSON-3807, http://issues.hudson-ci.org/browse/HUDSON-7091).

If you try to run a build on a job with a repo using HTTP auth, the process will hang at the repository checkout, as GIT is waiting for a password to be entered. Fortunately, you can set the credentials for the server access in a netrc file placed in your home directory.

Find your home directory:

  • If you are running Jenkins as the user you are currently logged in as:
    • Commonly, the home directory that GIT will use can be found by going start->Run and typing a “.” in the run dialog (without the quotes). On windows XP this is “C:\Documents and Settings\Administrator”
    • To be extra sure, you should open the GIT bash, type “cd” to go back to your home directory, and then enter “pwd” to show the current path.
  • If you are running Jenkins as a service
    • Create a new Execute Shell build step. Execute the command:
      echo $HOME
    • Run the build and examine the output to see where $HOME is located

Create the _netrc file:
On linux, this file is actually .netrc, however I found that on windows its using the underscore notation. When creating the _netrc file, ensure that your editor is saving the file using unix-line-endings. If you are using a tool like notepad++ this can be set by going Edit -> EOL Conversion -> UNIX Format.

_netrc contents:

machine <server name>
       login <server username>
       password <server password>

Where <server name> is the name of the server that hosts your GIT repository, and the username and password correspond to valid HTTP credentials. See the netrc page in references below for additional examples.

Verify the _netrc settings work by attempting to download the HEAD from the repository using curl:

curl --netrc --location -v http://<server_name>/<git_repo>.git/HEAD

This should return something like “ref: refs/heads/master“. If you get an authentication failed message, be sure to scroll up in the console to verify if curl was able to find the server entry in _netrc.

Gotachas:

  • If you specify the address to the GIT repository in Hudson in http://<username>@<server> notation, the _netrc data will not be picked up. This is because of the “<username>@” prefix
  • I had to modify the git executable I was using, as the default wasn’t picking up the _netrc file
    • Under Manage Hudson -> Configure -> Git Installation, point the default executable to the git.cmd script. Mine was at C:\Program Files\Git\cmd

References:
http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt
http://www.mavetju.org/unix/netrc.php

, ,

7 Comments