How can I get all build numbers of particular job in jenkins using groovy script?

前端 未结 3 786
南旧
南旧 2020-12-20 04:34

I am using active choice plugin, have groovy script which retrieves names of all jobs in Jenkins. Can I write a groovy script which get me list of all the build numbers of t

3条回答
  •  北海茫月
    2020-12-20 05:22

    Try:

    def xml=new XmlSlurper().parse("http:{serverName}/Jenkins/rssLatest")
    def projects = xml.entry.collect{(it.title as String).split("#")[0].trim()}
    println projects
    

    In general I suggest browsing your jenkins feed for the info you want then look for an "rss feed" -- then put that rss URL into the XmlSlurper and see what you get.

    Also I tend to work through these things in groovysh, it makes it really easy to explorer how objects work. In this case you might want to also be looking at the raw XML as you try objects in groovysh.

提交回复
热议问题