For a Jenkins pipeline job having web-hook trigger in Git/Bitbucket, each repo push triggers pipeline job.

How we can know branch name in pipeline job on which push/change is committed.

I need this branch name to execute pipeline job whenever push to specific branch happened (devel/master).

Note: Jenkins pipeline job is not s multibranch pipeline job.

  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
    – jayhendren
    Jan 10, 2018 at 17:31

1 Answer 1


This depends entirely on how you're triggering the jobs from Bitbucket. For instance, I am using the pull-request-notifier plugin for Bitbucket to trigger my jobs, and one of the parameters it offers is the branch that the pull request was created from. You can then feed this information into Jenkins however you want; one example would be to pass it as a parameter to a parameterized job. Different hooks or triggers will have different options available; some might not even offer the ability to pass the branch name.

However, I would highly recommend using the Bitbucket Branch Source plugin for Jenkins instead. It automatically creates Jenkins jobs for every branch and pull request of every project in a Bitbucket project. This makes it much, much easier to work in Jenkins with repositories that have multiple branches.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .