Create Continuous Integration (CI) Pipeline in Gitlab
Create Continuous Integration (CI) Pipeline in Gitlab Agenda What is Continuous Integration (CI)? What it is the application? How does a CI Pipeline work? What do I need for a CI Pipeline? What steps are necessary? Small Project in Python Server Configuration Python Project Gitlab CI Yaml File stages: - test python_test: stage: test image: python:3.9 script: - pip3 install pipenv - pipenv install - pipenv run python3 -m pytest Server Configuration Server Update # SSH Login ~ ssh root@IP-Adresse # Update Server root@server:~$ apt-get update && apt-get upgrade Create new user # Create new user root@server:~$ useradd -m -s /bin/bash youtube # Change Password root@server:~$ passwd youtube # Add user to sudo Group root@server:~$ usermod -aG sudo youtube Disable root access per ssh # Edit SSH Config youtube@server:~$ sudo vim /etc/ssh/sshd_config # inside vim /PermitRootLogin yes mit no ersetzen # on your keyboard :wq # Restart ssh service root@server:~$ sudo systemctl restart ssh Password-less login + Installation of Docker # on your Laptop / PC ~ ssh-copy-id youtube@server-IP # Login mit youtube ohne Passwort # Installation of Docker youtube@server:~$ sudo apt-get install -y docker.io # Adding user to docker group root@server:~$ usermod -aG docker $USER # Logout and login again Checking of docker installation # Testen der Docker Installation youtube@server:~$ docker ps # Beispiel Container starten youtube@server:~$ docker run hello-world Install Gitlab Runner # Start Gitlab Runner # Resource: https://docs.gitlab.com/runner/install/docker.html youtube@server:~$ docker run -d --name gitlab-runner --restart always -v /srv/gitlab-runner/config:/etc/gitlab-runner \ -v /var/run/docker.sock:/var/run/docker.sock \ gitlab/gitlab-runner:latest # Register Gitlab Runner-> write gitlab.com oder your Gitlab Instanz Resource: https://docs.gitlab.com/runner/register/ youtube@server:~$ docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register Downloads Presentation Python Project Helpful Links https://docs.gitlab.com/ee/ci/README.html https://docs.pytest.org/en/stable/ https://docs.docker.com/ https://docs.gitlab.com/runner/install/docker.html https://docs.gitlab.com/runner/register/ Icons https://www.flaticon.com/authors/becr https://www.flaticon.com/autho https://www.flaticon.com/authors/freepik