Instead of configuring it in the UI (as perfectly described by casey vega's answer, you can also do this within your Jenkinsfile:
Declarative Pipeline
Add the following condition within any stage directive:
when { anyOf { branch 'master'; branch 'release/**' } }
As you can see, it's possible to use exact branch names as well as some wildcards (ANT style path glob pattern). It's also possible to use regex and some more fancy conditions and combinations. Please have a look at Jenkins' offical docs on the when directive for reference and detailed information.
Scripted Pipeline
Just enclose the part you want to have run conditionally in the following code:
if (env.BRANCH_NAME == 'master' || (env.BRANCH_NAME).startsWith('release/')) {
// Your Pipeline goes here
}
This can be used almost everywhere within your (scripted) Jenkinsfile. As you can see, it's just some simple string comparison. For more complex Regex comparisons, take a look at Groovy's Find and Match operators, which also work fine here.
Conclusion
I would prefer using this method (although I recommended it otherwise some time ago), as you can then check-in your pipeline configuration into your source control and you're more on the Configuration-as-Code approach as when you configure it in your Jenkins UI.