Jenkins Integration

Last modified by Vincent Massol on 2019/05/01 19:56

cogShows how to integrate Jenkins in wiki pages
Developed by

Vincent Massol

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Jenkins offers a REST-like API which makes it easy to integrate.

Example

Shows how to display information about the "XWiki Rendering" project on http://ci.xwiki.org

{{groovy}}
def url = "https://ci.xwiki.org/job/XWiki/job/xwiki-rendering/api/xml".toURL().text
def root = new XmlSlurper().parseText(url)

println "|=|=XWiki Rendering"

println "|Last builds|${root.build.collect( { "[[${it.number}>>${it.url}]]" } ).join(", ")}"
println "|Build stability|[[image:http://ci.xwiki.org/static/89477826/images/32x32/${root.healthReport[0].iconUrl}]] ${root.healthReport[0].score}%"
println "|Test result|[[image:http://ci.xwiki.org/static/89477826/images/32x32/${root.healthReport[1].iconUrl}]] ${root.healthReport[1].score}%"
println "|Last Completed Build|[[${root.lastCompletedBuild.number}>>${root.lastCompletedBuild.url}]]"
println "|Last Failed Build|[[${root.lastFailedBuild.number}>>${root.lastFailedBuild.url}]]"

println "|Downstream projects|((("
root.downstreamProject.each() {
    println "* [[${it.name}>>${it.url}]]"
}
println ")))"

println "|Upstream project|(((* [[${root.upstreamProject.name}>>${root.upstreamProject.url}]])))"

println "|Modules|((("
root.module.each() {
    def color = it.color
   if (color == 'disabled') color = 'grey'
    println "|[[image:http://ci.xwiki.org/static/89477826/images/16x16/${color}.png]]|[[${it.name}>>${it.url}]]"
}
println ")))"

{{/groovy}}

Result:

jenkins.png

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Created by Vincent Massol on 2011/10/29 22:13
     

Get Connected