Answers: <p>I see (at least) two possible solutions that both have their drawbacks.</p>
  
  <ol>
  <li><p>Using a shared library containing all the code for your static analysis. That code can then be called as a step in the pipeline.  <a href="https://jenkins.io/doc/book/pipeline/shared-libraries/" rel="nofollow noreferrer">https://jenkins.io/doc/book/pipeline/shared-libraries/</a>. 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.</p></li>
  <li><p>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.</p></li>
  </ol>
  
Answers: CC BY-SA 4.0
Answers: 2018-12-07T09:06:52.047Z
Answers: 2018-12-07T09:06:52.047Z
Answers: Johan
Body: <p>I'm just starting to get my toes wet with Jenkins and CI/CD.</p>
  
  <p>I've built a set of static analysis tools and corresponding configurations I want to run before a branch's Jenkinsfile is even considered. I want to have Jenkins run these tools across every branch regardless of what the Jenkinsfile on the branch says. I want to make sure that the static analysis is out of the purview of the repo. How can I build a set of steps that are run before the Jenkinsfile on the branch is considered? </p>
  
Tags: <jenkins><jenkinsfile>
Title: Jenkins Pipeline steps that run before Jenkinsfile
UserDisplayName: seanr8
ThreadText: # Jenkins Pipeline steps that run before Jenkinsfile
  
  (Asked by: username_0 on 2018-12-05)
  
  I'm just starting to get my toes wet with Jenkins and CI/CD.
  
  I've built a set of static analysis tools and corresponding configurations I want to run before a branch's Jenkinsfile is even considered. I want to have Jenkins run these tools across every branch regardless of what the Jenkinsfile on the branch says. I want to make sure that the static analysis is out of the purview of the repo. How can I build a set of steps that are run before the Jenkinsfile on the branch is considered?
  
  **Tags:** jenkins, jenkinsfile
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-07. Score: 1
  
  I see (at least) two possible solutions that both have their drawbacks.
  
  1. 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.
  2. 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.
  
  
  ---
  
  