Jenkins Pipeline steps that run before Jenkinsfile
I see (at least) two possible solutions that both have their drawbacks.


Using a shared library containing all the code for your static analysis. That code can then be called as a step in the pipeline.  https://jenkins.io/doc/book/pipeline/shared-libraries/. This doesn't keep the execution out of the pipeline completely, but it keeps the code out of each pipeline/branch and is (in my opinion) a pretty straight forward solution.
Putting the static analysis into a separate job, trigger that job for example with a git hook and then let that job trigger the pipeline. I my opinion a more complex solution that has more moving parts, but may be closer to what you're asking for.