# gitlab ![image alt](https://docs.gitlab.com/ee/ci/introduction/img/gitlab_workflow_example_extended_v12_3.png) # The admin user can perform any action on GitLab CI/CD in scope of the GitLab instance and project. In addition, all admins can use the admin interface under /admin/runners. | Action | Guest, Reporter | Developer | Maintainer | Admin | | ------ | -------- | -------- | -------- | -------- | | See commits and jobs | ✓ | ✓ | ✓ | ✓ | | Retry or cancel job | | ✓ | ✓ | ✓ | |Erase job artifacts and job logs | | ✓ | ✓ | ✓ | | Delete project | | | ✓ | ✓ | | Create project | | | ✓ | ✓ | | Change project configuration | | | ✓ | ✓ | | Add specific runners | | | ✓ | ✓ | | Add shared runners | | | ✓ | ✓ | | See events in the system | | | | ✓ | | Admin interface | | | | ✓ | # 定義的環境變量,我們可以獲取分支名,提交的消息,從而判斷任務是否需要執行;而Web界面Settings/CI-CD設置的變量,則非常適合用於存儲像公私鑰,賬號密碼這些不便公開的數據。因為只有Owner和Maintainer能夠查看。 # .gitlab-ci.yml 腳本的keyword | Key | Reqired | Description | | ------ | -------- | -------- | | image | 否 | 使用Docker鏡像 | | service | 否 | 使用Docker服務 | | stages | 否 | 定義購欠階段 | | types | 否 | stages 別名(建議只使用stages,已經被廢棄) | | before_script | 否 | 每個腳本任務執行之前執行的腳本 | | after_script | 否 | 每個腳本任務執行之後執行的腳本 | | variables | 否 | 定義變量,可以在構建階段使用 | | cache | 否 | 定義緩存文件,可以在後面階段使用到 | ## job job 是 .gitlab-ci.yml 裡的頂級元素了,任何自動化部署都必須有的,個人認為可以將它分成任務,每個任務里至少包含一條腳本表明在此任務裡要做的事情。可以定義多個 job 並且每一個 job 之間都是相互獨立的,job 會被 Gitlab Runner 在自己的環境下執行。