简体   繁体   中英

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. Vice versa if main branch has a commit, jenkins sometimes fetches from feature-0 branch. How can I ensure it fetches the right branch when webhook triggers?

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. feature-0 branch has a different commit message and it triggered the jenkins job.

I've specified main and feature in the branches section. 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. Then it started checking out the source branch that triggered the webhook.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM