Multibranch Pipeline git events on PR

34 views
Skip to first unread message

Gautam, Rishi

unread,
Feb 10, 2021, 5:31:39 AM2/10/21
to jenkins...@googlegroups.com
I was trying to carry out git operations on any other branch than the PR source/destination branch in a jenkins multibranch pipeline.
When I scanned the branches inside the PR build job, I didn't see any other branches. I only got below branches on git branch -a command on pipeline:
* PR-2
  remotes/origin/PR-2
  remotes/upstream/stage

There are other branches like test,master. Are there any workarounds to this?

Gautam, Rishi

unread,
Feb 15, 2021, 4:49:21 AM2/15/21
to jenkins...@googlegroups.com
anyone has any idea please

Dirk Heinrichs

unread,
Feb 15, 2021, 4:59:30 AM2/15/21
to jenkins...@googlegroups.com
Am Mittwoch, den 10.02.2021, 16:16 +0545 schrieb Gautam, Rishi:

I was trying to carry out git operations on any other branch than the PR source/destination branch in a jenkins multibranch pipeline.
When I scanned the branches inside the PR build job, I didn't see any other branches. I only got below branches on git branch -a command on pipeline:
* PR-2
  remotes/origin/PR-2
  remotes/upstream/stage

Any chance the job configuration contains a branch filter?

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
signature.asc

Ivan Fernandez Calvo

unread,
Feb 15, 2021, 2:57:01 PM2/15/21
to Jenkins Users
Check if you have set git references on the job, IIRC the git plugin always make a `git fetch —all`

Mark Waite

unread,
Feb 15, 2021, 3:41:14 PM2/15/21
to Jenkins Users
The multibranch pipeline implementation on one or more of the branch providers intentionally narrows the refspec of the repository while cloning it into the workspace.  The narrowed refspec usually includes only a single branch so that git does not waste effort retrieving changes that are not related to the branch being built.  That narrow refspec 

If you need more branches available in the workspace, you may need to use a checkout scm step within your pipeline definition that specifically chooses to use the wider refspec that you need for the additional branches you're trying to access.

Refspecs are described in the "repostories" section of the git plugin documentation and in the command line git documentation.

Example checkout steps can be generated with the Pipeline Syntax snippet generator from your Jenkins controller.  A brief video clip on using the snippet generator is linked from the git plugin documentation.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/691d1a51-5ae2-4004-8e56-7c3fa3f6a17an%40googlegroups.com.

Gautam, Rishi

unread,
Mar 14, 2021, 11:58:11 PM3/14/21
to jenkins...@googlegroups.com
This was finally solved by doing unshallow clone of git repositories.
Configure Multibranch Pipeline Job > Branch Sources > Behaviours > Add > Advanced clone behaviours > uncheck shallow clone 
image.png

Thank you everyone for the help.

Reply all
Reply to author
Forward
0 new messages