I\'m trying to use Jenkins file for all our builds in Jenkins, and I have following problem. We basically have 3 kind of builds:
1) I don't know if it is appropriate, but if it resolves your problem, I think is appropriate enough.
2) In order to know the name of the branch you can use BRANCH_NAME variable, its name is taken from the branch name.
${env.BRANCH_NAME}
Here is the answer: Jenkins Multibranch pipeline: What is the branch name variable?