drone 使用git tag觸發構建


配置ref為tag

.drone.yml中配置trigger為ref

trigger:
  ref:
  - refs/tags/FileService

或者配置when為ref

when:
  ref:
  - refs/tags/FileService

注意: trigger應用於整個pipeline, when應用於step

也就是trigger會觸發這條pipeline,而when決定了跑這條pipeline時會不會跳過這個step

ref是數組,可以配置多個

trigger:
  ref:
  - refs/tags/FileService
  - refs/tags/IdentityService

也支持通配符 refs/tags/** 表示所有的tag, refs/tags/v* 表示v開頭的tag

還支持include包含 和exclude排除, 下面的代碼表示包含IdentityService和File開頭的tag, 除了FileService

trigger:
  ref:
    include:
    - refs/tags/IdentityService
    - refs/tags/File*
    exclude:
    - refs/tags/FileService

 

git 添加和推送tag

在完成代碼提交和推送到遠程后,對剛剛推送的提交添加tag

git tag -f FileService
git push -f origin FileService

兩行命令都加-f參數,表示強制覆蓋.因為同名tag只能有一個,所以更新需要覆蓋之前的.第一行是為最近的提交添加一個名為FileService的tag,第二行是推送到遠程倉庫. 推送完成才會觸發對應的pipeline

 

總結: 這種用tag觸發對應pipeline的方式適用於單分支進行多pipeline構建,而多分支直接用branch作為trigger或when的參數更好. 

注意: drone不支持同時使用tag和branch作為觸發條件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM