[英]Gitlab-jenkins webhook triggers build with wrong branch
我一直在嘗試使用 gitlab 網絡掛鈎設置構建觸發器到我的 Jenkins 自由式項目,
為了那個原因,
In Jenkins, added gitlab connection, added the ssh url and specified the branch I need to build in the git
plugin's Branches to build
section,
此外,安裝Gitlab
插件后,選擇Build Triggeres
> gitlab webhook url
現在 webhook 可以工作,並且在 repo 更改時會觸發構建,
但問題是Jenkins 從 web 鈎子觸發時在不同的分支上構建項目,
到目前為止我所做的,
origin/master
、 origin/feature
、 origin/test
)發生更改時,列表中的第一個即主獲取構建而不是指定的test
分支。比較在直接 jenkins 構建和 gitlab webhook 觸發構建時執行的 git 命令顯示了這種差異,(使用 refspec 修改)
# on successful build
> git fetch --no-tags --progress --depth=5 -- git@gitlab.com:<project_name>.git +refs/heads/test:refs/remotes/origin/test # timeout=10
> git rev-parse origin/test^{commit} # timeout=10
# when triggered via webhook (it switches to master at last)
> git fetch --no-tags --progress --depth=5 -- git@gitlab.com:<project_name>.git +refs/heads/test:refs/remotes/origin/test # timeout=10
> git config remote.origin.url git@gitlab.com:<project_name>.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/test:refs/remotes/origin/test # timeout=10
Avoid second fetch
> git rev-parse remotes/origin/master^{commit} # timeout=10
所有有變化的分支都顯示在構建部分而不是test
分支中,
這是我需要這個項目從遠程提取的唯一分支,
使用 Jenkins 版本2.303.3
JDK 8,插件版本 Gitlab: 1.5.22
, Git: 4.10.0,
有人可以為此提出任何解決方案,
截至目前,它僅在從 gitlab 測試 web-hook 時構建錯誤的分支,
定期更改時,按照 Jenkins 和 gitlab 中的規定構建所需的分支,如果這樣做,請務必使用 gitlab 中的分支過濾器,
很明顯,在測試 web-hook 時,gitlab 為所有發生更改的分支發送觸發器,在 Jenkins 中發生了什么我假設它在接收此類觸發器時構建默認分支,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.