Jenkins Integration
Last modified by Vincent Massol on 2021/03/18 11:28
![]() | Shows how to integrate Jenkins in wiki pages |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
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}}
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: