The good thing about being into dev-ops is that you get to learn a lot. Sometimes it’s more sort of revision than being able to JUST ACCOMPLISH A TASK. I have used GITLAB quite a few times but never installed it myself for the staging environment. Here’s a quick start guide with on how to setup GitLab with CI/CD runner on an AWS instance.
For those interested they can refer to the following doc :
In short take an AMI for GitLab on m2.large instance on AWS. And rest is just plug and play on click of a button.
Once GitLab for CI/CD you have to configure the RUNNER.
SSH into your system where your GitLab is running.
Add GitLab offical repo :
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
Install the latest version of GitLab Runner, or skip to the next step to install a specific version:
sudo apt-get install gitlab-runner
sudo yum install gitlab-runner
Register the runner
To register runner type
sudo gitlab-runner register
Enter your GitLab instance URL:
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
Enter Token for your runner
Please enter the gitlab-ci token for this runner xxx
NOTE : You will find this runner in your admin settings>token. Be very careful in putting the token.
Enter a description for the Runner
Please enter the gitlab-ci description for this runner [hostame]
Enter the tags associated with the Runner, you can change this later in GitLab’s UI:
Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag
After couple of more options of configuration :
Enter the runner exectuor [ssh, docker etc.] [Preference : choose docker]
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: docker
If you chose Docker as your executor, you’ll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml:
Please enter the Docker image (eg. ruby:2.1): alpine:latest
Once completed you’ll have your runner up and running.
In case you are configuring the runner ONLY then in that case you have to download the docker package for your distro.
In order to have execute the runner everytime a code change is pushed please include
.gitlab-ci.ymlin your project.
<br /># Official framework image. Look for the different tagged releases at: # https://hub.docker.com/r/library/python image: python:latest # Pick zero or more services to be used on all builds. # Only needed when using a docker container to run your tests in. # Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service services: - mysql:latest # This folder is cached between builds # http://docs.gitlab.com/ce/ci/yaml/README.html#cache cache: paths: - ~/.cache/pip/ # This is a basic example for a gem or script which doesn't use # services such as redis or postgres before_script: - python -V - pip install -r requirements/development.txt test: variables: DATABASE_URL: "mysql://root:root@localhost:5432/$MYSQL_DB" script: - flake8 - py.test
For environment variables go to repo-settings and put your env variables/secret there.
Jira Integration :
ref docs : ![Jira Integration]
ref docs : ![Slack Integration]
THAT’S ALL FOLKS