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.
CodePudding user response:
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.