持续集成环境Gitlab CI的官方安装过程解析(2)

 

  # Setup tables sudo -u gitlab_ci -H bundle exec rake db:setup RAILS_ENV=production # Setup scedules # sudo -u gitlab_ci -H bundle exec whenever -w RAILS_ENV=production 7. Install Init Script

Download the init script (will be /etc/init.d/gitlab_ci):

sudo wget https://raw.github.com/gitlabhq/gitlab-ci/master/lib/support/init.d/gitlab_ci -P /etc/init.d/ sudo chmod +x /etc/init.d/gitlab_ci

Make GitLab start on boot:

sudo update-rc.d gitlab_ci defaults 21

Start your GitLab instance:

sudo service gitlab_ci start # or sudo /etc/init.d/gitlab_ci restart 8. Nginx Installation sudo apt-get install nginx Site Configuration

Download an example site config:

sudo wget https://raw.github.com/gitlabhq/gitlab-ci/master/lib/support/nginx/gitlab_ci -P /etc/nginx/sites-available/ sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci

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 {

#设置访问gitlab_ci的地址
listen 192.168.47.46:9292;
server_name 192.168.47.46;

root /home/gitlab_ci/gitlab-ci/public;

access_log /var/log/nginx/gitlab_ci_access.log;
error_log /var/log/nginx/gitlab_ci_error.log;

location / {
try_files $uri $uri/index.html $uri.html @gitlab_ci;
}

location @gitlab_ci {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;

proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;

proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;

proxy_pass ;
}
}

  Restart sudo /etc/init.d/nginx restart 9. Runners Requirements

The project is designed for the Linux operating system.

We officially support (recent versions of) these Linux distributions:

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

Enjoy!

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/18939.html