Jenkins 在 webhook 触发时获取错误的分支

Jenkins fetching wrong branch when webhook triggers

当 gitlab feature-0 提交并触发 jenkins webhook 时,jenkins 从 Main 分支而不是 feature-0 分支拉取。反之亦然,如果 main 分支有提交,jenkins 有时会从 feature-0 分支获取。如何确保它在 webhook 触发时获取正确的分支?

Fetching changes from the remote Git repository
skipping resolution of commit remotes/origin/feature-0, since it originates from another repository
Multiple candidate revisions
Checking out Revision 1cda3cd8cb747c8588daaf07715499ea37927d8b (origin/main)
Commit message: "Please retry a full pipeline [ci build]"

以上提交信息来自main分支。 feature-0 分支有不同的提交消息,它触发了 jenkins 作业。

我在分支部分指定了 main 和 feature。但它没有按预期工作。

已解决:

我不得不在 Jenkins 中将分支名称更改为 ${gitlabSourceBranch},并且在管道中 运行 git 结帐时还删除了 branch 名称。然后它开始检查触发 webhook 的源分支。