简体   繁体   中英

How to get Script Path from each Jenkins Jobs using Groovy Console Script/Jenkins API

I have a requirement to fetch Script path from Jenkins Job.

Please find the below screenshot to understand the requirement more clearly.

在此处输入图像描述

I have checked in google to get some Groovy Console Script which lists details of each Job.

By using the jenkins.model.Jenkins.getJobNames() method,i was able to get all Jobs in Jenkins, but actually the requirement is to get the Scriptpath value, mentioned inside each those jobs.

Which Jenkins Class/method can provide those details or is any other way to fetch those details using Jenkins API?

By reading the config.xml for each job and getting the Scriptpath tag from it will also give me the information needed, But I was looking for a REST method or Jenkins Groovy Script method which can give me this Script path Information for each Job.

  1. Open your job configuration page.
  2. Change the configure at the end of url to config.xml and press Enter
  3. The new opening page loads xml content
  4. Find Scriptpath value in tag <scriptPath>xxxxxx</scriptPath>

So you can send http requset to job's confim.xml url and parse the content to get the value programmatically

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM