1. 程式人生 > >記一次Drone無法觸發構建的問題

記一次Drone無法觸發構建的問題

# 問題 好巧不巧,當你晚上準備上線的時候,在下午臨近下班的時候CICD工具出問題了,提交程式碼不能觸發構建,不能上線了,Drone那邊負責人也下班了,正好CICD關聯的公司git倉庫也出問題了(就是上次Drone構建失敗被誤會的部門),我們的構建服務也沒有相關的報錯日誌,就順水推鍋取消了上線。 # 定位 問題沒有定位出來,晚上(別人下班後)立馬check線上的版本,把中間過程的日誌都記錄一下看看問題出在哪 ## CICD流程及日誌定位 梳理CICD流程,簡易的流程圖如下: ![](https://images.cnblogs.com/cnblogs_com/surging-dandelion/1867895/o_210305054558drone-cicd.png) 只有管理系統是我們自己的,部署驗證,相關日誌如下: ``` 2021-03-05 10:41:16.796 [XNIO-2 task-309] INFO - ==============部署管理系統,環境:env-new-test=============== 2021-03-05 10:41:16.800 [XNIO-2 task-309] INFO - ==============cloneDir:/tmp/datahub/env-new-test,gitUrl:http://gitlab.xxx.cn/xxx/env-new-test.git=============== 2021-03-05 10:41:16.800 [XNIO-2 task-309] INFO - ==============拉取程式碼=============== 2021-03-05 10:41:18.089 [XNIO-2 task-309] INFO - ==============拉取程式碼=============== 2021-03-05 10:41:18.099 [XNIO-2 task-309] INFO - ==============deployLogs:businessline-engine:0.1.675,mark-center-new:1.0.124-release.995,*******=============== 2021-03-05 10:41:18.107 [XNIO-2 task-309] INFO - ==============git push=============== ``` 沒有報錯日誌,Git提交也成功了,但是就是沒有觸發構建(上面的鍋推錯了) ## 柳暗花明 第二天一上班,拉著大佬討論,大佬看了一下,果然和公司git倉庫那邊沒有關係(我們沒用,drone也沒依賴);一般drone沒有觸發構建原因有二: 1、自己設定的event限制(可自查) 2、repo session過期 (可關閉repo開關,sync repo後再開啟開關) ### event限制 這個其實是drone.yml裡面的pipeline.deploy.when的配置,相關配置如下: ``` pipeline: deploy: image: cicd-maven-***:1.0.2 when: event: - push branch: master ``` 這玩意八百年沒有變過,所以直接排除。 ### repo session過期 drone的repo session過期機制不是太清楚(後面有機會再研究),直接在drone的右上角點開Repositories選單,把repo的開關先關閉再開啟,再次提交恢復正常。自此問題解決,在此記錄一下,證君清白 # 後續來了 大佬指出來,這個過期和你的Cookie過期有關係,儘量不要保持cookies,使用的時候重新登入基本就會避免這個問題,問題的原因基本就浮出水面了,我們先查閱一下官網:[傳送門](https://docs.drone.io/server/cookie/) Drone uses cookies to authenticate client requests and maintain the user session. This document provides resources for customizing cookie creation. Drone signs authentication cookies using a secret key that is randomly generated when the server starts. Every time you restart the server a new key is generated, which means existing sessions are terminated. We can avoid terminating existing sessions on restart by providing the server with a static secret key. Drone creates cookies with a default timeout of 30 days. When the cookie expires the user sessions is terminated and the user will be required to login. You can customize the cookie timeout through the environment. 意思是Drone的cookie預設會保持30天,如果Repository的操作人有超過30天沒有重新登入,Cookie就會過期,會導致上述問題出現,這樣基本就能解釋清楚了 回顧一下最近幾個月Drone構建失敗的原因: - 第一次:之前Git Repository的負責人離職,當時盲猜是git帳號被清理,批量失敗(現在看來應當和這次的原因一樣),重新關閉開啟repo解決 - 第二次:Drone映象倉庫快取不生效,阿里雲映象加速服務連線超時 - 第三次:cookie過期,重新關閉開啟re