gitlab Auto DevOps

在上一次實驗中有發現這個Auto DevOps大概來測試一下

.gitlab-ci.yml

code
stages:
  - test

run_my_tests:
  stage: test
  script:
    - echo "Running custom test script..."
    - ./run_tests.sh
  only:
    - main
code
chmod +x run_tests.sh
git add .gitlab-ci.yml run_tests.sh
git commit -m "Add CI/CD pipeline and test script"
git push main

這邊可以看到pipeline被卡住了 image image 創建一個專案執行器 image 應該是類似一個執行環境 image

gitlab-runner config.toml

調整設定gitlab-runner 設定

code
vim /etc/gitlab-runner/config.toml
code
concurrent = 1
check_interval = 0
log_level = "debug"

[[runners]]
  name = "HOME-X213212"
  url = "http://127.0.0.1"
  token = "glrt-SCv…DEb4"
  executor = "shell"
  shell = "bash"

gitlab-runner run

code
sudo gitlab-runner run

試了三小時結果是wsl runnner版本太舊 sudo curl -L --output /usr/local/bin/gitlab-runner "https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-arm64" 用這個下載最新的 在push 一次 image 發現訪問不到 gitlab.example.com 然後加個dns

dns gitlab.example.com

code
vim  /etc/hosts
127.0.1.1       gitlab.example.com

在push 一次 image

.gitlab-ci.yml

來微調一下看能不能run push python 腳本

code
stages:
  - run_script

run_shell_script:
  stage: run_script
  script:
    - echo "About to run script..."
    - python3 test.py
    - echo "Script completed with exit code $?"

image image

看起來 gitlab 內建autodevops 功能算蠻強大的