Sorry I can't help, but that's an excellent question. I was about to ask it
myself (although I build _merged_ heads for PRs).

There don't seem to be any suitable environment variables, so the only
option I can think of is to interrogate the Multibranch Plugin, which may
or may not have the original branch name in it somewhere. I haven't worked
which class to use yet.

On 1 October 2016 at 01:17, 'Logan Glickfield' via Jenkins Users <
[email protected]> wrote:

> Hi there!
>
> Is there any way to get the original feature branch name within a pipeline
> that was triggered by a PR build rather than the "PR-#" style BRANCH_NAME?
>
> I've tried things like:
> scm checkout
> def branch = sh(returnStdout: true, script: 'git rev-parse --abbrev-ref
> HEAD').trim()
>
> But that doesn't work because its actually on a detached head commit with
> no branch.
>
>
> Our Github Organization is currently configured to use:
> - Build origin branches
> - Build origin PRs (unmerged head)
>
> We also specify "Include branches" so that we only build the "master PR-*"
> branches.
>
> It seems like I could use "Build origin branches also filed as PRs" and
> get the correct BRANCH_NAME for free. But if I understand correctly,
> "Include branches" would become useless and I would no longer be able to
> configure it to build only the "master" branch and pull request branches.
>
> Anyone have any ideas how I might be able to make this work?
>
> Thanks!
>
> -Logan
>
> --
> 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/3135bfee-2501-4814-8555-af0c79551112%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/3135bfee-2501-4814-8555-af0c79551112%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGi586PC32G5Kmfi89gJufvsA8nTuFLJJF94m5acsBLXbqn3qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to