5

Is there any way to save a pipeline configuration or an item configuration in Git or anywhere else, so that when my Jenkins machine is crashed, i can migrate the saved configuration in the new Jenkins instance?

Ann
  • 63
  • 1
  • 3
  • 6

3 Answers3

5

All your jobs is stored in config.xml files inside $JENKINS_HOME/jobs/<path_to_your_job> folders. So, you can just backup these config.xml files (or you can backup all Jenkins configuration by saving full $JENKINS_HOME folder).

biruk1230
  • 3,042
  • 4
  • 16
  • 29
5

I would ( as a start ) get yourself - https://wiki.jenkins.io/display/JENKINS/JobConfigHistory+Plugin which keeps history of all Changes made to Jobs , System config etc - has saved me multiple times.

Also , you could setup a cron job outside Jenkins to git push your Job config.

I setup to push the Jobs folder content ( including Build history - but you could exclude that - Correctly ignore all files recursively under a specific folder except for a specific file type ref ) .

My script ( i had SSH stuff previously setup )

cd /this/that/other/jenkins_data/jobs/
NOW=$(date +"%m-%d-%Y-%r")
git add .
git commit -m "Jenkins Backup $NOW"
git push -u origin jenkins-backup

This way gives me piece of mind , I have RSYNC to another box and I also have a Backup plugin running too... ( i was stung once - not again! )

Hope this helps.

Gripsiden
  • 467
  • 2
  • 15
0

Hi you can write the pipeline script in file and publish that file into the git.

After that just create the pipeline job in the jenkins and use Pipeline script from SCM option for pipeline script.

The other option is take backup of Jenkins home directory to external hard disk(keep project workspace outside the jenkins home to reduce backup size).

Amit Nanaware
  • 3,203
  • 1
  • 6
  • 19
  • Thank you for the reply, "Pipeline script from SCM" is the script part right,iam asking about the configuration part of the pipeline, suppose i have a pipeline, pipeline x and in the configuration i have added it as a parameterized pipeline, and in the configuration i have also mentioned it as a"Pipeline script from SCM" and i have also scheduled this pipeline, this whole configuration setup of pipeline x, can i save it anywhere? – Ann Jan 15 '19 at 05:32
  • Yes you can mention this also in pipeline script. Go to any job and click on `Pipeline Syntax` at left side select `Declarative Directive Generator` and from dropdown select the option you want and click on generate you will get the syntax. add it in your pipeline script and done – Amit Nanaware Jan 15 '19 at 05:57