CI(Continuous Integration)是Devops的軟體開發流程,主要針對程式碼變更後的自動建置和測試之後,定期將變更合併置主要Repository,CI的關鍵目標是能更快發現和解決問題、改善軟體品質還有減少驗證和釋出軟體更新所需的時間。
此篇文章將教你如何建立Gitlab CI流程
環境說明:
- Gitlab (self-managed)
- Gitlab Runner
- Docker (windows)
首先在Docker上安裝Gitlab-Runner,輸入以下指令安裝Docker
sudo docker run -itd --restart always --name gitlab-runner \
-v /etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner
p.s.如果gitlab網址是HTTPS協定,則需要加上ssl的相關設定
-e CA_CERTIFICATES_PATH=/etc/gitlab-runner/certs/server.crt \
-e LOCAL_CA_PATH=/usr/local/share/ca-certificates/ \
查看Docker是否有建立成功(Running表示有成功)
建立Runner前先去專案內找到Registration toeken,路徑 Settings>CI/CD>Runners
開啟終端機介面,並輸入Gitlab-runner開始建立project runner,
# gitlab-runner register
Enter the GitLab instance URL (for example, https://gitlab.com/):
<PLACE YOUR GITLAB URL>
Enter the registration token:
<PLACE YOUR TOKEN HERE>
Enter a description for the runner:
[4b3193ddb657]:
Enter tags for the runner (comma-separated):
build,test
Enter optional maintenance note for the runner:
Registering runner... succeeded runner=GR1348941LEDi2FSZ
Enter an executor: virtualbox, kubernetes, custom, docker, parallels, ssh, docker-ssh, shell, docker+machine, docker-ssh+machine:
docker
Enter the default Docker image (for example, ruby:2.7):
nodejs
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
沒有留言:
張貼留言