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: image.png]

Thank you everyone for the help.

On Tue, Feb 16, 2021 at 2:26 AM Mark Waite <[email protected]>
wrote:

> 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"
> <https://plugins.jenkins.io/git/#using-repositories> section of the git
> plugin documentation and in the command line git documentation
> <https://git-scm.com/book/en/v2/Git-Internals-The-Refspec>.
>
> Example checkout steps can be generated with the Pipeline Syntax snippet
> generator
> <https://www.jenkins.io/doc/book/pipeline/getting-started/#snippet-generator>
> from your Jenkins controller.  A brief video clip on using the snippet
> generator is linked from the git plugin documentation
> <https://plugins.jenkins.io/git/#pipelines>.
>
> Mark Waite
>
> On Mon, Feb 15, 2021 at 12:57 PM Ivan Fernandez Calvo <
> [email protected]> wrote:
>
>> Check if you have set git references on the job, IIRC the git plugin
>> always make a `git fetch —all`
>>
>> El lunes, 15 de febrero de 2021 a las 10:49:21 UTC+1, Rishi Gautam
>> escribió:
>>
>>> anyone has any idea please
>>>
>>> On Wed, Feb 10, 2021 at 4:16 PM Gautam, Rishi <[email protected]>
>>> wrote:
>>>
>>>> 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?
>>>>
>>>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/691d1a51-5ae2-4004-8e56-7c3fa3f6a17an%40googlegroups.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/691d1a51-5ae2-4004-8e56-7c3fa3f6a17an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHHg-XkDiqiStxFfHjuf1ANAKAjLHGMLx75RvHr%3DyfARQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHHg-XkDiqiStxFfHjuf1ANAKAjLHGMLx75RvHr%3DyfARQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAF4beLj64_d0voM0%2BBtnyQRzhHxKXL3avKsr4Y%2B96p5FFbB_oQ%40mail.gmail.com.

Reply via email to