How to merge two git branches in a pipeline script

Hi Guys,

I am unable to find a solution to merge two git branches in a pipeline as script code. Below is my code developed so far to checkout and merge. Only checkout step is working. Please advise what can i need to complete the merge process in one stage.

stage(“code checkout and merge”) {
steps {
checkout( [
$class: ‘GitSCM’,
branches: [[name: “refs/heads/dev”]],
userRemoteConfigs: [
[credentialsId: ‘test_key’,
url: ‘url.git’]
]
]
)
}
}

Thanks,
kumar.

You probably want to use an sh step to directly call git commands. This then becomes a git question that you can resolve outside of Jenkins. There are a lot of good resources out there to answer it. You can start with the official git documentation on Basic Branching and Merging.

2 Likes