[英]Jenkins fetching wrong branch when webhook triggers
When gitlab feature-0
has a commit and it triggers jenkins webhook, jenkins pulls from Main branch instead of feature-0
branch.当 gitlab feature-0
提交并触发 jenkins webhook 时,jenkins 从 Main 分支而不是feature-0
分支拉取。 Vice versa if main
branch has a commit, jenkins sometimes fetches from feature-0
branch.反之亦然,如果main
分支有提交,jenkins 有时会从feature-0
分支获取。 How can I ensure it fetches the right branch when webhook triggers?我如何确保它在 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]"
The above commit message is from main
branch.上面的提交消息来自main
分支。 feature-0
branch has a different commit message and it triggered the jenkins job. feature-0
分支有不同的提交消息,它触发了 jenkins 作业。
I've specified main and feature in the branches section.我在分支部分指定了 main 和 feature。 But it isn't working as expected.但它没有按预期工作。
Resolved it:解决了它:
I had to change the branch name to ${gitlabSourceBranch}
in Jenkins and also remove branch
names when running git checkout in pipeline.我必须在 Jenkins 中将分支名称更改为${gitlabSourceBranch}
并且在管道中运行 git 结帐时也删除branch
名称。 Then it started checking out the source branch that triggered the webhook.然后它开始检查触发 webhook 的源分支。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.