Hi Rob,

I have script to add Maven configuration through groovy script and it is 
working fine. i need similar kind of script for sonar and artifactory.

maven3.groovy


import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
a=Jenkins.instance.getExtensionList(hudson.tasks.Maven.DescriptorImpl.class)[0];
b=(a.installations as List);
b.add(new hudson.tasks.Maven.MavenInstallation("MAVEN3", 
"/home/jenkins/apache-maven/apache-maven-3.2.3", []));
a.installations=b
a.save()

command line to execute.
java -jar jenkins-cli.jar -s  http://localhost:8080/ groovy maven3.groovy

-Ankush

On Monday, 10 November 2014 19:03:44 UTC+5:30, Rob Mandeville wrote:
>
>  If you want to configure your Jenkins service via Groovy, you need the 
> Groovy plugin.  This allows you to run a “System Groovy Script”.  This runs 
> in the same JVM as the server.
>
>  
>
> This gives you the raw capabilities.  I don’t know of one particular 
> reference to tell you how to do what you’re trying to do.  You may need to 
> get the javadoc for your server and for the plugins you wish to configure.  
> I don’t have the code here, but at a previous position I was able to use 
> this capability to enable and disable slave nodes as part of a Jenkins job.
>
>  
>
> You may also want to look at the Scriptler plugin.  This will allow easier 
> storage of your Groovy configuration scripts, and easier execution of them 
> within a Jenkins job.
>
>  
>
> Hope this helps!
>
>  
>
> --Rob Mandeville
>
>  
>
>  
>  
> *From:* jenkins...@googlegroups.com <javascript:> [mailto:
> jenkins...@googlegroups.com <javascript:>] *On Behalf Of *Ankush Aggarwal
> *Sent:* Monday, November 10, 2014 7:30 AM
> *To:* jenkins...@googlegroups.com <javascript:>
> *Subject:* Groovy script to do jenkins configuration
>  
>  
>  
> Hi All,
>  
>  
>  
> I have installed sonar and artifactory plugin in jenkins. I want to do 
> both sonar and artifactory configurations via groovy script.
>  
>  
>  
> I am able to do using GUI Manage Jenkins -> configure system but need to 
> do similar activity via groovy script.
>  
>  
>  
> Anyone please help me on this.
>  
>  
>  
> Thanks,
>  
> Ankush
>  
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jenkinsci-use...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>  Click here 
> <https://www.mailcontrol.com/sr/xlCCm2w16k!GX2PQPOmvUtVTDJsKpCsgkXmJl7Mxg1r+EDfsm14EugAM3OsLei9chu5YqLyvUFSzR1Lppn2zgQ==>
>  
> to report this email as spam.
>  
> ------------------------------
> This e-mail and the information, including any attachments it contains, 
> are intended to be a confidential communication only to the person or 
> entity to whom it is addressed and may contain information that is 
> privileged. If the reader of this message is not the intended recipient, 
> you are hereby notified that any dissemination, distribution or copying of 
> this communication is strictly prohibited. If you have received this 
> communication in error, please immediately notify the sender and destroy 
> the original message.
>
> Thank you.
>
> Please consider the environment before printing this email.
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to