Daniel vijay Sundar
Daniel vijay Sundar

Reputation: 343

How to get jenkins job description using shell

I wanted to take the description given for each job in jenkins. Is there any way of getting it by shell script?

Upvotes: 0

Views: 1128

Answers (2)

Perplexabot
Perplexabot

Reputation: 1989

Access your jenkins master node:

ssh <jenkins_user>@<jenkins_master_node>

Locate then go to jobs directory:

cd /jenkins/jobs/

Then do this:

find . -type f -iname config.xml | xargs grep -m1 "description"

Basically every Jenkins job you create has a respective config.xml on your master with all the information you entered in the Jenkins UI. One of the entries in this config.xml is a description tag that you write when making a job. I have limited the output to only show the first description in the config.xml files. You can remove the -m1 to see all the descriptions.

Upvotes: 2

Ian W
Ian W

Reputation: 4767

Use Groovy from the script console.

items = Jenkins.instance.allItems.findAll {
   // Gets all jobs in the portfolio
   it instanceof hudson.model.FreeStyleProject
}

items.each {
  println it.fullName + " : " + it.description
}
return

Upvotes: 0

Related Questions