-1

I am trying to update the description and name of the jobs in Jenkins using python . So how can it be done .

1 Answers1

0

This is not a very straightforward task, and will require you to edit the job config XML files.

The official Jenkins API only provides limited functionality related to running builds. However, since all Jenkins job details are stored within the config.xml, you can use this to your advantage. You would have to run this script in you Jenkins server, and have it modify the config.xml found in the root Jenkins directory. If you were to open this file, you would see all the job names defined here. Changing those would result in the references to jobs being changed. However, the jobs themselves would not have actually changed. To make that happen, go to jenkins\home\jobs, and would find a list of folders named after jobs. You have to change the name of the folder to match the updated name as well.

Once you have followed these steps, you would have changed the job name. To change the job description, you need to go into the individual folder named after the job. There, you will find another config.xml. Open this up and you would find the job description. Changing this description will result in the job description being changed.

So those are the steps to changing the job name and description. All of it can be automated using Python. Additionally, you might want to take a look at the jenkinsapi package:

pip install jenkinsapi

This package has a getConfig function that can get the necessary config files. More on that in this answer.

M B
  • 2,700
  • 2
  • 15
  • 20
  • Can you please share a example or just a code by which i can get reference of how to change description of job in jenkins using config.xml in python language – MRINMOY DEB May 20 '22 at 06:55