install ant via groovy?

36 views
Skip to first unread message

str...@gmail.com

unread,
Mar 10, 2016, 5:11:28 AM3/10/16
to Jenkins Users
Hi,

i am looking for a way to configure the ant-plugin via groovy. Can anybody point me to an example or doc?
I have been searching for a while now without success.

regards,
Roman

Victor Martinez

unread,
Mar 10, 2016, 7:53:18 AM3/10/16
to Jenkins Users
I've done something similar for Maven, see below

import hudson.tasks.Maven
import hudson.tools.InstallSourceProperty
import jenkins.model.Jenkins

def mvn2 = new Maven.MavenInstallation('maven_2.3.3', null, [new InstallSourceProperty([new Maven.MavenInstaller('2.3.3')])])
def mvn3 = new Maven.MavenInstallation('maven_3.3.3', null, [new InstallSourceProperty([new Maven.MavenInstaller('3.3.3')])])
def mvnList = [mvn2, mvn3]

mvnDescriptor = Jenkins.instance.getExtensionList(hudson.tasks.Maven.DescriptorImpl.class)[0];
currentMvnList = (mvnDescriptor.installations as List);

mvnList.each {
    println "INFO: adding '${it.getName()}'"
    currentMvnList.add(it)
    mvnDescriptor.installations = currentMvnList
    mvnDescriptor.save()
}

You can look at the below javadoc:

I hope it helps
Reply all
Reply to author
Forward
0 new messages