繁体   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