Giriş
Açıklaması şöyle
The Gitlab software was created by Valery Sizov and Dmytro Zaporozhets in 2013. The software was written in Ruby, and Go was used to rewrite some parts later on. The current tool involves Ruby on Rails, Go, and Vue.js programming languages. GitLab Inc. was launched in 2014 with San Francisco as its headquarters. Initially, it was free and open-source. In 2013, it was split into two versions; Enterprise and Community Editions. In 2017, the company announced that Gitlab would be offered as an open-source tool under an MIT license. Today, the company operates in 67 countries with 1280 employees.
GitLab Flow
Açıklaması şöyle
GitLab Flow has a main principle: upstream first, there is only one main branch master, which is the upstream of all other branches, so the merge order is very important, such as the development environment is (master), pre-release The environment is (pre-production), and the production environment is (production).
If the production environment sends an error, you need to pull out a hotfix branch first, merge it into master after modification, merge it into pre-production after acceptance, and then accept it again. Merge to production, the above steps cannot be skipped unless it is an emergency.
GitLab CI/CD
GitLab CI/CD'nin amacı GitLab'a commit yapılınca projeyi tekrar bizim sunucumuza deploy etmek diye düşünülebilir. Açıklaması şöyle
Here is how Gitlab works:
1. Create a structured order of CI/CD jobs in the GitLab-ci.yml configuration file and store this file in the project root directory. The CI/CD pipeline contains four important stages: build, test, staging, and production.
2. Install a runner for your project and register it.
3. When a config file is pushed to the repository, the runner executes the CI/CD based on the predefined conditions.
4. When the script passes all these stages, it is automatically deployed to production.
Kavramlar
Pipeline
Açıklaması şöyle
In GitLab CI/CD, a pipeline is a collection of stages and jobs that specify the actions to be taken for a certain branch or tag in your repository. You may automate the testing and deployment processes by having each pipeline start when a new commit or merge request occurs.
Stages
Açıklaması şöyle. Her stage içinde Job vardır. Job, Runner tarafından çalıştırılır
Stages reflect the pipeline steps, including build, test, and deploy. You specify one or more jobs—individual units of work — within each level. Jobs can operate on separate runners (such as virtual machines, containers, or Kubernetes pods), either concurrently or sequentially.
Runners
Açıklaması şöyle. Her stage içinde Job vardır. Job, Runner tarafından çalıştırılır
GitLab CI/CD employs runners to conduct the tasks listed in your pipeline. GitLab offers both shared runners and customized runners that you may build up on your own infrastructure. Your builds and tests will always run because GitLab Runners watch for new jobs and run them in secure, isolated environments.
image Alanı
maven:3-jdk-11
Örnek - multi-module
1. parent .gitlab-ci.yml tanımlanır. Burada extends ile child modul'ün parametreleri alınır ve job
çalıştırılır yaparız. .build-module build aşamasında çalıştırılır. Ondan kalıtan build-common-module
aynı zamanda .common-module den de kalıtır ve common-module derlenir
.build-module:stage: build script: - echo "Building $MODULE" - mvn -pl $MODULE clean compile --also-make artifacts: expire_in: 10 min paths: - "*/target" # BUILD JOBS build-common-module: extends: - .common-module - .build-module
Örnek - parallel
Bir örnek burada
Örnek
AWS EKS örneği burada
Örnek
.gitlab-ci.yml şöyle olsun
stages:- build- deploymaven-build:image: maven:3-jdk-11stage: buildscript: "mvn package -B"artifacts:paths:- target/gitlab-ci-demo.jardeploy-master:rules:- if: '$CI_COMMIT_BRANCH =~ /^master$/'before_script:- apt-get update -qq && apt-get install -y -qq sshpassstage: deployscript:- sshpass -V- export SSHPASS=$CI_USER_PASS- sshpass -e scp -o StrictHostKeyChecking=no
target/gitlab-ci-demo.jar gitlab-ci@167.172.188.139:/home/gitlab-ci- sshpass -e ssh -tt -o StrictHostKeyChecking=no
gitlab-ci@167.172.188.139 sudo mv /home/gitlab-ci/gitlab-ci-demo.jar
/opt/java/webapps- sshpass -e ssh -tt -o StrictHostKeyChecking=no
gitlab-ci@167.172.188.139 sudo systemctl restart gitlab-ci-demo.service
Hiç yorum yok:
Yorum Gönder