簡體   English   中英

Gitlab-jenkins webhook 觸發器使用錯誤的分支構建

[英]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, Git 插件分支說明符

    此外,安裝Gitlab插件后,選擇Build Triggeres > gitlab webhook url

  • 下一步,在 gitlab 中創建傳出 webhook 並添加 url, 指定分支的 Gitlab webhook

現在 webhook 可以工作,並且在 repo 更改時會觸發構建,
但問題是Jenkins 從 web 鈎子觸發時在不同的分支上構建項目

到目前為止我所做的,

  • 在進一步檢查時,當多個分支(即origin/masterorigin/featureorigin/test )發生更改時,列表中的第一個即主獲取構建而不是指定的test分支。
  • 當直接從 jenkins 構建時,它會拉出正確的分支,那里沒有問題,
  • 我已經根據這個stack-overflow answer修改了配置。 例如提到'refspec'並添加高級克隆行為和淺克隆,但似乎沒有任何效果,

比較在直接 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM