&
linux
+
+
+
+
+
+
android
deno
+
+
+
+
aws
+
+
js
neo4j
angular
+
+
scipy
+
+
vscode
+
+
0b
json
mint
js
git
+
^
clickhouse
https
0b
elm
centos
oauth
+
+
unix
ubuntu
+
babel
grpc
&&
+
$
โˆš
axum
symfony
+
+
+
babel
jquery
ฮป
+
+
pnpm
+
asm
tcl
+
+
!=
+
java
preact
+
jasmine
+
aws
+
composer
+
sublime
+
yaml
emacs
debian
+
+
+
apex
Back to Blog
๐Ÿš€ GitLab CI/CD Pipeline Automation on AlmaLinux: DevOps Made Simple
gitlab cicd almalinux

๐Ÿš€ GitLab CI/CD Pipeline Automation on AlmaLinux: DevOps Made Simple

Published Aug 29, 2025

Master GitLab CI/CD on AlmaLinux! Learn installation, pipeline creation, runners, Docker integration, and automation. Complete beginner's guide to DevOps!

5 min read
0 views
Table of Contents

๐Ÿš€ GitLab CI/CD Pipeline Automation on AlmaLinux: DevOps Made Simple

Welcome to the exciting world of automated DevOps! ๐ŸŽ‰ Ready to stop manually deploying code and start automating everything? GitLab CI/CD is your personal robot army that builds, tests, and deploys your code automatically! Itโ€™s like having a team of developers working 24/7 without coffee breaks! โ˜•โœจ

๐Ÿค” Why is GitLab CI/CD Important?

GitLab CI/CD transforms how teams deliver software! ๐ŸŒŸ Hereโ€™s why itโ€™s revolutionary:

  • ๐Ÿ”„ Continuous Integration - Automatically test every code change
  • ๐Ÿ“ฆ Continuous Deployment - Deploy to production with confidence
  • ๐Ÿšซ Zero Manual Errors - Robots donโ€™t make typos!
  • โšก Lightning Fast Delivery - From code to production in minutes
  • ๐Ÿ›ก๏ธ Built-in Security - Scan for vulnerabilities automatically
  • ๐Ÿ“Š Complete Visibility - See every pipeline stage in real-time

Think of GitLab CI/CD as your personal DevOps assistant that never sleeps! ๐Ÿค–

๐ŸŽฏ What You Need

Before automating your workflow, ensure you have:

  • โœ… AlmaLinux server (8 or 9)
  • โœ… Root or sudo access
  • โœ… At least 4GB RAM (8GB recommended)
  • โœ… 50GB free disk space
  • โœ… Basic Git knowledge
  • โœ… Enthusiasm for automation! ๐ŸŽฏ

๐Ÿ“ Step 1: Installing GitLab - Your DevOps Platform!

Letโ€™s install GitLab CE (Community Edition)! ๐Ÿ—๏ธ

First, install dependencies:

# Install required packages
sudo dnf install -y curl policycoreutils openssh-server perl

# Enable OpenSSH server
sudo systemctl enable sshd
sudo systemctl start sshd

# Install Postfix for email notifications
sudo dnf install -y postfix
sudo systemctl enable postfix
sudo systemctl start postfix

Add GitLab repository and install:

# Add GitLab repository
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

# Install GitLab CE (this takes a few minutes!)
sudo EXTERNAL_URL="http://gitlab.example.com" dnf install -y gitlab-ce

# Replace gitlab.example.com with your domain or IP!

Configure GitLab:

# Configure GitLab (this takes 5-10 minutes)
sudo gitlab-ctl reconfigure

# Check status
sudo gitlab-ctl status

You should see all services running! ๐ŸŽ‰

๐Ÿ”ง Step 2: Initial Setup - Creating Your Admin Account!

Time to set up your GitLab instance! ๐ŸŽฏ

Get the initial root password:

# GitLab generates a random password
sudo cat /etc/gitlab/initial_root_password

# Save this password! It's only valid for 24 hours!

Configure firewall:

# Open GitLab ports
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Access GitLab:

  1. Open browser to http://your-server-ip
  2. Login with username: root
  3. Use the password from /etc/gitlab/initial_root_password
  4. Change password immediately!

Create your first project:

  1. Click โ€œNew Projectโ€
  2. Choose โ€œCreate blank projectโ€
  3. Name it โ€œhello-worldโ€
  4. Make it public or private
  5. Initialize with README

Perfect! GitLab is ready! ๐Ÿš€

๐ŸŒŸ Step 3: Setting Up GitLab Runner - Your Build Agent!

GitLab Runner executes your CI/CD jobs! Letโ€™s install it:

# Add GitLab Runner repository
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash

# Install GitLab Runner
sudo dnf install -y gitlab-runner

# Check version
gitlab-runner --version

Register the runner with GitLab:

# Start registration
sudo gitlab-runner register

# You'll be prompted for:
# 1. GitLab URL: http://your-gitlab-server
# 2. Registration token: (get from Project Settings > CI/CD > Runners)
# 3. Description: my-runner
# 4. Tags: docker,linux
# 5. Executor: docker
# 6. Docker image: alpine:latest

Install Docker for the runner:

# Install Docker
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io

# Start Docker
sudo systemctl start docker
sudo systemctl enable docker

# Add gitlab-runner to docker group
sudo usermod -aG docker gitlab-runner

# Restart runner
sudo gitlab-runner restart

Verify runner is connected:

  1. Go to Project Settings > CI/CD > Runners
  2. You should see your runner online! โœ…

โœ… Step 4: Creating Your First Pipeline - Automation Magic!

Letโ€™s create a CI/CD pipeline! Create .gitlab-ci.yml in your project:

# .gitlab-ci.yml - Your pipeline configuration!

# Define stages - what happens in what order
stages:
  - build
  - test
  - deploy

# Variables used across jobs
variables:
  APP_NAME: "hello-world"
  DEPLOY_PATH: "/var/www/html"

# Before every job, do this
before_script:
  - echo "๐Ÿš€ Starting CI/CD Pipeline!"
  - echo "๐Ÿ“… Date: $(date)"
  - echo "๐Ÿท๏ธ Branch: $CI_COMMIT_BRANCH"

# BUILD STAGE - Compile your code
build-job:
  stage: build
  image: node:16-alpine  # Docker image to use
  script:
    - echo "๐Ÿ”จ Building application..."
    - npm install
    - npm run build
    - echo "โœ… Build complete!"
  artifacts:
    paths:
      - dist/  # Save build output
    expire_in: 1 hour
  only:
    - main  # Only run on main branch

# TEST STAGE - Run your tests
test-job:
  stage: test
  image: node:16-alpine
  script:
    - echo "๐Ÿงช Running tests..."
    - npm install
    - npm test
    - echo "โœ… All tests passed!"
  coverage: '/Coverage: \d+\.\d+%/'
  only:
    - main
    - develop

# DEPLOY STAGE - Ship to production!
deploy-job:
  stage: deploy
  image: alpine:latest
  script:
    - echo "๐Ÿš€ Deploying to production..."
    - apk add --no-cache openssh-client
    - echo "๐Ÿ“ฆ Copying files to server..."
    # Add your deployment commands here
    - echo "โœ… Deployment successful!"
    - echo "๐ŸŒ Application is live at $APP_URL"
  environment:
    name: production
    url: http://your-app.com
  only:
    - main
  when: manual  # Require manual approval

Commit and watch the magic:

# In your project directory
git add .gitlab-ci.yml
git commit -m "Add CI/CD pipeline"
git push origin main

# Go to GitLab > CI/CD > Pipelines
# Watch your pipeline run! ๐ŸŽŠ

๐Ÿ”’ Step 5: Advanced Pipeline Features - Power User Mode!

Letโ€™s add advanced features to your pipeline! ๐Ÿ’ช

Docker Build and Push:

# Build and push Docker images
docker-build:
  stage: build
  image: docker:latest
  services:
    - docker:dind  # Docker in Docker
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: "/certs"
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - echo "๐Ÿณ Building Docker image..."
    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    - docker push $CI_REGISTRY_IMAGE:latest
    - echo "โœ… Image pushed to registry!"

Security Scanning:

# Security scan with GitLab
security-scan:
  stage: test
  image: registry.gitlab.com/gitlab-org/security-products/analyzers/secrets:latest
  script:
    - echo "๐Ÿ” Scanning for secrets..."
    - /analyzer run
  artifacts:
    reports:
      secret_detection: gl-secret-detection-report.json

Multi-environment Deployment:

# Deploy to different environments
.deploy-template:
  stage: deploy
  image: alpine:latest
  script:
    - echo "๐Ÿ“ฆ Deploying to $CI_ENVIRONMENT_NAME..."
    - # Your deployment script

deploy-staging:
  extends: .deploy-template
  environment:
    name: staging
    url: http://staging.example.com
  only:
    - develop

deploy-production:
  extends: .deploy-template
  environment:
    name: production
    url: http://example.com
  only:
    - main
  when: manual

๐Ÿ“Š Step 6: Monitoring and Optimization - Pipeline Analytics!

Set up monitoring for your pipelines! ๐Ÿ“ˆ

Enable pipeline metrics:

# In gitlab.rb
sudo nano /etc/gitlab/gitlab.rb

# Add these lines:
gitlab_rails['prometheus_enabled'] = true
gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '::1/128']

# Reconfigure
sudo gitlab-ctl reconfigure

Create pipeline badges for your README:

# In your README.md
![Pipeline Status](https://gitlab.example.com/your-project/badges/main/pipeline.svg)
![Coverage](https://gitlab.example.com/your-project/badges/main/coverage.svg)

Set up notifications:

# Slack notifications in .gitlab-ci.yml
notify-slack:
  stage: .post
  image: appropriate/curl:latest
  script:
    - |
      curl -X POST -H 'Content-type: application/json' \
      --data "{\"text\":\"โœ… Pipeline succeeded for $CI_PROJECT_NAME!\"}" \
      $SLACK_WEBHOOK_URL
  when: on_success

๐ŸŽฎ Quick Examples

Example 1: Python Application Pipeline

Complete Python CI/CD:

stages:
  - test
  - build
  - deploy

test-python:
  stage: test
  image: python:3.9
  script:
    - pip install -r requirements.txt
    - pytest tests/ --cov=app
    - flake8 app/
  coverage: '/TOTAL.*\s+(\d+%)$/'

build-python:
  stage: build
  image: python:3.9
  script:
    - python setup.py bdist_wheel
  artifacts:
    paths:
      - dist/*.whl

Example 2: Kubernetes Deployment

Deploy to K8s cluster:

deploy-k8s:
  stage: deploy
  image: bitnami/kubectl:latest
  script:
    - kubectl config use-context $K8S_CONTEXT
    - kubectl set image deployment/$APP_NAME $APP_NAME=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    - kubectl rollout status deployment/$APP_NAME

Example 3: Database Migrations

Run database updates:

migrate-database:
  stage: deploy
  image: migrate/migrate
  script:
    - migrate -path migrations -database $DATABASE_URL up
  only:
    changes:
      - migrations/*

๐Ÿšจ Fix Common Problems

Problem 1: Pipeline Fails Immediately

Symptom: Jobs fail with โ€œNo runner availableโ€ ๐Ÿ˜ฐ

Fix:

# Check runner status
sudo gitlab-runner status

# Verify runner is registered
sudo gitlab-runner list

# Re-register if needed
sudo gitlab-runner register

# Check runner logs
sudo journalctl -u gitlab-runner -f

Problem 2: Docker Permission Errors

Symptom: โ€œPermission deniedโ€ when using Docker ๐Ÿณ

Fix:

# Add gitlab-runner to docker group
sudo usermod -aG docker gitlab-runner

# Restart services
sudo systemctl restart docker
sudo gitlab-runner restart

# Verify permissions
sudo -u gitlab-runner docker ps

Problem 3: Artifacts Not Found

Symptom: Next stage canโ€™t find artifacts ๐Ÿ“ฆ

Fix:

# Ensure artifacts are defined correctly
build:
  artifacts:
    paths:
      - build/
    expire_in: 1 week

# Dependencies in next job
test:
  dependencies:
    - build  # Explicitly depend on build job

๐Ÿ“‹ Simple Commands Summary

CommandWhat It DoesWhen to Use
gitlab-ctl statusCheck GitLab servicesHealth check
gitlab-ctl reconfigureApply configurationAfter changes
gitlab-runner registerRegister new runnerAdd build capacity
gitlab-runner listShow runnersCheck runners
gitlab-runner verifyCheck runner healthTroubleshooting
gitlab-rails consoleGitLab consoleAdvanced admin
gitlab-rake gitlab:checkSystem checkDiagnose issues
gitlab-backup createCreate backupBefore upgrades
gitlab-ctl tailView logsDebug problems
gitlab-psqlDatabase consoleDatabase tasks

๐Ÿ’ก Tips for Success

๐Ÿš€ Performance Optimization

Make pipelines blazing fast:

# Cache dependencies
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
    - .npm/

# Parallel jobs
test:
  parallel: 3
  script:
    - npm test

# Only run on changes
only:
  changes:
    - src/**/*
    - tests/**/*

๐Ÿ”’ Security Best Practices

Keep your CI/CD secure:

  1. Use CI/CD variables - Never hardcode secrets! ๐Ÿ”
  2. Protected branches - Restrict who can deploy! ๐Ÿ›ก๏ธ
  3. Signed commits - Verify code authenticity! โœ๏ธ
  4. SAST scanning - Find vulnerabilities early! ๐Ÿ”
  5. Manual approvals - Human verification for production! ๐Ÿ‘ค
# Set protected variables
# Project Settings > CI/CD > Variables
# Mark as "Protected" and "Masked"

๐Ÿ“ˆ Monitoring Excellence

Track everything:

# Enable monitoring
sudo gitlab-ctl prometheus-monitoring enable

# Access metrics
curl http://localhost:9090/metrics

# Grafana dashboards
http://your-gitlab:3000

๐Ÿ† What You Learned

Youโ€™re now a GitLab CI/CD master! ๐ŸŽ“ Youโ€™ve successfully:

  • โœ… Installed GitLab on AlmaLinux
  • โœ… Set up GitLab Runners
  • โœ… Created CI/CD pipelines
  • โœ… Configured Docker integration
  • โœ… Implemented advanced features
  • โœ… Learned troubleshooting
  • โœ… Mastered automation

Your DevOps workflow is now automated! ๐Ÿค–

๐ŸŽฏ Why This Matters

GitLab CI/CD gives you superpowers! With your automation pipeline, you can:

  • ๐Ÿš€ Deploy fearlessly - Tests catch bugs automatically!
  • โฑ๏ธ Save hours daily - No more manual deployments!
  • ๐ŸŽฏ Focus on coding - Let robots handle the boring stuff!
  • ๐Ÿ“Š Track everything - Complete deployment history!
  • ๐Ÿ›ก๏ธ Ship securely - Automated security scanning!

Youโ€™re not just automating deployments - youโ€™re implementing modern DevOps practices that leading tech companies use! Your code now flows from development to production like a well-oiled machine! ๐ŸŒŸ

Keep automating, keep innovating, and remember - with GitLab CI/CD, every commit can be a deployment! โญ

May your pipelines be green and your deployments be smooth! ๐Ÿš€๐Ÿ’š๐Ÿ™Œ