Project

General

Profile

JenkinsGroovy » History » Version 7

Andreas Kohlbecker, 08/14/2013 11:12 PM

1 1 Andreas Kohlbecker
2
# Groovy Scripts for Jenkins
3
4
5
You can evaluate groovy scripts in the Jenkins _Script Console_.
6
7
8
There are several plugins which can be _programmed_ with Groovy:
9
10 4 Andreas Kohlbecker
* [Groovy plugin](https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin)
11
12
* [Dynamic Parameter Plug-in](https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Dynamic+Parameter+Plug-in)
13
14
* [Groovy Remote Control](http://groovy.codehaus.org/modules/remote/)
15
16
* [Scriptler plugin](https://wiki.jenkins-ci.org/display/JENKINS/Scriptler+Plugin)
17 1 Andreas Kohlbecker
18
19
20
----
21
22
23 6 Andreas Kohlbecker
### Get all versions of an artifact from a maven repository
24
25 1 Andreas Kohlbecker
~~~
26
def metadata = new XmlSlurper().parse("http://wp5.e-taxonomy.eu/mavenrepo/eu/etaxonomy/cdm-server/maven-metadata.xml")
27 5 Andreas Kohlbecker
metadata.versioning.versions.version.each{
28
	  println "> " + it
29 1 Andreas Kohlbecker
}
30
~~~
31 2 Andreas Kohlbecker
32
doc:
33
34
* http://groovy.codehaus.org/api/groovy/util/XmlSlurper.html
35 3 Andreas Kohlbecker
36 1 Andreas Kohlbecker
* http://www.ibm.com/developerworks/java/library/j-pg05199/
37 6 Andreas Kohlbecker
38
39 7 Andreas Kohlbecker
the same for the **Dynamic Parameter Plug-in** which is very nice in conjunction with the *[Repository Connector Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Repository+Connector+Plugin) 
40 6 Andreas Kohlbecker
41
42
~~~
43
def metadata = new XmlSlurper().parse("http://wp5.e-taxonomy.eu/mavenrepo/eu/etaxonomy/cdm-server/maven-metadata.xml")
44
def list = []
45
metadata.versioning.versions.version.each{
46
  list.add(it)
47
}
48
return list
49
~~~