It is a bit pricy if you want to host code for collaboration using bitbucket or github on your own VPS or On-Premisis servers. Gitlab in midst of this provides a community edition which is packed with essential features and also free of cost. Both Editions ship with CI integrated in it and also can handle 3rd party CI applications like Jenkins or Bamboo ..etc.,
In this Tutorial you will see
- Installation of GITLAB
- Configuring CI + Runners
Test Environment: Ubuntu 14.04 on VPS with 2 cores/4 GB RAM
sudo apt-get install curl openssh-server ca-certificates
Official Gitlab suggests the use of postfix, but you can use other email delivery solutions like Sendgrid or Mailchimp, which provide 10,000+ emails/month.
Use Bash Script provided by GITLAB to add repository to apt-package list:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Then Install using command
sudo apt-get install gitlab-ce
This will Install Gitlab, now we need to make following changes to configuration information in /etc/gitlab/gitlab.rb and run gitlab-ctl reconfigure to apply the changes
external_url "<gitlab endpoint url>"
For details regarding smtp settings you can visit this link. which has settings for various smtp mail providers.
After Reconfiguring. You can navigate to gitlab in web browser and set password. Note that default credentials are root/<password-set>.
Gitlab CI + Runners:
For Security reasons it is not preferrable to run Test cases in same server as Gitlab CE+CI Instances. But we can use Docker to advantage and run the test cases in Isolated Environments which is safe.
Install Docker with following command
curl -fsSL https://get.docker.com/ | sh
Install Gitlab Runner by
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash sudo apt-get install gitlab-ci-multi-runner
Register it your gitlab instance by
sudo gitlab-ci-multi-runner register Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci ) <gitlab endpoint url>/ci Please enter the gitlab-ci token for this runner Can find in admin area runners section (shared runner) or project Runners Section (Project Specific Runner) Please enter the gitlab-ci description for this runner my-runner Please enter the executor: shell, docker, docker-ssh, ssh? docker Please enter the Docker image: python-ci:latest INFO Runner registered successfully. Feel free to start it,
Thus you successfully set up both CE + CI + Runners.
Create a GITLAB Project and Push your Project with test cases in it. you should see builds running.
Visit this Video Tutorial in case you're struck somewhere.