Resolved... Both scripts are ready to use...
===========================
Sonar Script
==========================
import jenkins.model.*
import hudson.plugins.sonar.*
import hudson.plugins.sonar.model.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("hudson.plugins.sonar.SonarPublisher")
def sinst = new SonarInstallation(
"sonar4.5.1",
false,
"http://localhost:9000/",
"jdbc:mysql://localhost:3306/sonar",
"com.mysql.jdbc.Driver",
"sonar",
"sonar",
"",
"-Dsonar.sourceEncoding=\"UTF-8\"",
new TriggersConfig(),
"admin",
"admin"
)
desc.setInstallations(sinst)
desc.save()
==================================================
Artifactory Script
==================================================
import jenkins.model.*
import org.jfrog.*
import org.jfrog.hudson.*
import org.jfrog.hudson.util.Credentials;
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("org.jfrog.hudson.ArtifactoryBuilder")
def deployerCredentials = new Credentials("admin", "password")
def resolverCredentials = new Credentials("", "")
def sinst = [new ArtifactoryServer(
"server-id",
"http://localhost:8081/artifactory",
deployerCredentials,
resolverCredentials,
300,
false )
]
desc.setArtifactoryServers(sinst)
desc.save()
On Monday, 10 November 2014 20:02:58 UTC+5:30, Rob Mandeville wrote:
>
> Sorry, I don’t know how to help you more there.
>
>
>
> --Rob
>
>
>
> *From:* [email protected] <javascript:> [mailto:
> [email protected] <javascript:>] *On Behalf Of *Ankush Aggarwal
> *Sent:* Monday, November 10, 2014 9:05 AM
> *To:* [email protected] <javascript:>
> *Cc:* Rob Mandeville
> *Subject:* Re: Groovy script to do jenkins configuration
>
>
>
> 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:* [email protected] [mailto:[email protected]] *On
> Behalf Of *Ankush Aggarwal
> *Sent:* Monday, November 10, 2014 7:30 AM
> *To:* [email protected]
> *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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
> Click here <https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==> 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 [email protected] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
> ------------------------------
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.