1

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?

0

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.