mkdir /tmp/ruby && cd /tmp/ruby
curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xz
cd ruby-1.9.3-p392
./configure
make
sudo make install
Install the Bundler Gem:
sudo gem install bundler --no-ri --no-rdoc
3. Prepare the database
You can use either MySQL or PostgreSQL.
MySQL
# Install the database packages
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
# Login to MySQL
$ mysql -u root -p
# Create the GitLab CI database
mysql> CREATE DATABASE IF NOT EXISTS `gitlab_ci_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# Create the MySQL User change $password to a real password 这里的 $password密码需要替换为你希望的密码
mysql> CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '$password';
# Grant proper permissions to the MySQL User
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost';
PostgreSQL
# Install the database packages
sudo apt-get install -y postgresql-9.1 libpq-dev
# Login to PostgreSQL
sudo -u postgres psql -d template1
# Create a user for GitLab. (change $password to a real password) 这里的 $password密码需要替换为你希望的密码
template1=# CREATE USER gitlab_ci WITH PASSWORD '$password';
# Create the GitLab production database & grant all privileges on database
template1=# CREATE DATABASE gitlab_ci_production OWNER gitlab_ci;
# Quit the database session
template1=# \q
# Try connecting to the new database with the new user
sudo -u git -H psql -d gitlab_ci_production
sudo -u gitlab_ci -H bundle --without development test postgres --deployment
sudo -u gitlab_ci -H bundle --without development test postgres --deployment
#
# PRODUCTION
#
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlab_ci_production
pool: 5
username: gitlab_ci
password: "travelchallenge" #这里设置你的先前设置的gilab_ci的密码
# host: localhost
# socket: /tmp/mysql.sock
#
# Development specific
#
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlab_ci_development
pool: 5
username: debian-sys-maint
password: "r0VpzdDxG33ruj0m"
# socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &test
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlab_ci_test
pool: 5
username: debian-sys-maint
password: "r0VpzdDxG33ruj0m"
# socket: /tmp/mysql.sock
Make sure to edit the config file to match your setup:
# Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
# to the IP address and fully-qualified domain name
# of your host serving GitLab CI
sudo vim /etc/nginx/sites-enabled/gitlab_ci
#下面是gitlab_ci的例子
upstream gitlab_ci {
server unix:/home/gitlab_ci/gitlab-ci/tmp/sockets/gitlab-ci.socket;
}
server {
Requirements The project is designed for the Linux operating system.
We officially support (recent versions of) these Linux distributions:
Ubuntu Linux
Debian/GNU Linux
Installation
# Get code
git clone https://github.com/gitlabhq/gitlab-ci-runner.git
# Enter code dircd gitlab-ci-runner
# Install dependencies
# a) Linux
sudo apt-get install libicu-dev
# b) MacOSx (make sure you have brew installed)
sudo brew install icu4c
gem install bundler
bundle install
# Install runner in interactive mode
bundle exec ./bin/install
# SSH into your GitLab server and confirm to add host key to known_hosts
ssh git@<your gitlab url>
Run
bundle exec ./bin/runner
Autostart Runners
On linux machines you can have your runners operate like daemons with the following steps
# make sure you install any system dependancies first
administrator@server:~$ sudo adduser --disabled-login --gecos 'GitLab CI Runner' gitlab_ci_runner
administrator@server:~$ sudo su gitlab_ci_runner
gitlab_ci_runner@server:/home/administrator$ cd ~/
# perform the setup above
gitlab_ci_runner@server:~$ exit;
gitlab_ci_runner@server:/home/gitlab_ci_runner$ sudo cp ./gitlab-ci-runner/lib/support/init.d/gitlab_ci_runner /etc/init.d/gitlab-ci-runner
gitlab_ci_runner@server:/home/gitlab_ci_runner$ cd ~
administrator@server:~$ sudo chmod +x /etc/init.d/gitlab-ci-runner
administrator@server:~$ sudo update-rc.d gitlab-ci-runner defaults 21
administrator@server:~$ sudo service gitlab-ci-runner start Done!
#这个得注意,这条告诉你用gitlab的密码来登录gitlab_ci 而不是 什么admin@local.host Visit YOUR_SERVER for your first GitLab CI login. You should use your GitLab credentials in orider to login