How do I replicate a Jenkins setup via automation?

HOW TO -️ October 18, 2021

I have a Jenkins setup running in production. I want to automate the Jenkins setup (installation) along with all the jobs that are set up in Jenkins.

One crude way I can think of is to copy the whole jobs directory to the new Jenkins setup.

How do I deal with this problem?


What did you try? I did a standard Jenkins setup and then put the jobs directory of original Jenkins setup in New Jenkins setup. It works. but I am looking for a better way. Possible duplicate of How do you back up Jenkins jobs & master configs?