You might need to debug your script a bit further as you can see in the STDERROR
Could not find matching constructor for: hudson.plugins.sonar.SonarInstallation(java.lang.String, java.lang.Boolean, jav a.lang.String, java.lang.String, java.lang.String, java.lang.String, java. lang.S tring, java.lang.String, java.lang.String, hudson.plugins.sonar.model. TriggersCo nfig, java.lang.String, java.lang.String) I believe you are a Sonar plugin version which doesn't support that constructor, you will need to check that, probably it-s worth if you check your sonar version and check the source code too: - https://github.com/SonarSource/jenkins-sonar-plugin/blob/master/src/main/java/hudson/plugins/sonar/SonarInstallation.java My two cents On Tuesday, 2 February 2016 10:03:58 UTC, Anurag Sernapally wrote: > > > > On Tuesday, November 11, 2014 at 1:41:49 PM UTC+5:30, Ankush Aggarwal > wrote: >> >> 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] [mailto:[email protected]] >>> *On Behalf Of *Ankush Aggarwal >>> *Sent:* Monday, November 10, 2014 9:05 AM >>> *To:* [email protected] >>> *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]. >>> For more options, visit https://groups.google.com/d/optout. >>> >>> ------------------------------ >>> Hi Ankush, >>> >> > I have installed sonar plugin using "jenkins_plugin" but while > configuring it with groovy scripts I am getting this error. I am pretty new > to chef so can you help me understand what I am missing. I am using same > code as you have suggested above > > > > ============================================================================ > ==== > Error executing action `execute` on resource 'jenkins_script[sonar]' > > ============================================================================ > ==== > > Mixlib::ShellOut::ShellCommandFailed > ------------------------------------ > Expected process to exit with [0], but received '255' > ---- Begin output of "java" -jar "/var/chef/cache/jenkins-cli.jar" -s > http:/ > /localhost:8080 groovy /tmp/groovy20160202-14365-1vd8grq ---- > STDOUT: > STDERR: Unexpected exception occurred while performing groovy command! > groovy.lang.GroovyRuntimeException: Could not find matching > constructor for: > hudson.plugins.sonar.SonarInstallation(java.lang.String, > java.lang.Boolean, jav > a.lang.String, java.lang.String, java.lang.String, java.lang.String, > java.lang.S > tring, java.lang.String, java.lang.String, > hudson.plugins.sonar.model.TriggersCo > nfig, java.lang.String, java.lang.String) > at > groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1491) > at > groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1407) > at > org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callCon > structor(MetaClassConstructorSite.java:46) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstru > ctor(CallSiteArray.java:54) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor > (AbstractCallSite.java:182) > at RemoteClass.run(RemoteClass:20) > at > groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.j > ava:266) > at groovy.lang.GroovyShell.run(GroovyShell.java:517) > at hudson.cli.GroovyCommand.run(GroovyCommand.java:86) > at hudson.cli.CLICommand.main(CLICommand.java:238) > at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:92) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. > java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at > hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvo > cationHandler.java:608) > at > hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocat > ionHandler.java:583) > at > hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocat > ionHandler.java:542) > at hudson.remoting.UserRequest.perform(UserRequest.java:120) > at hudson.remoting.UserRequest.perform(UserRequest.java:48) > at hudson.remoting.Request$2.run(Request.java:326) > at > hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecut > orService.java:68) > at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:63) > at > hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapte > r.java:18) > at > hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.ja > va:21) > at > jenkins.util.ContextResettingExecutorService$2.call(ContextResettingE > xecutorService.java:46) > at java.util.concurrent.FutureTask.run(FutureTask.java:262) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor. > java:1145) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor > .java:615) > at java.lang.Thread.run(Thread.java:745) > ---- End output of "java" -jar "/var/chef/cache/jenkins-cli.jar" -s > http://l > ocalhost:8080 groovy /tmp/groovy20160202-14365-1vd8grq ---- > Ran "java" -jar "/var/chef/cache/jenkins-cli.jar" -s > http://localhost:8080 g > roovy /tmp/groovy20160202-14365-1vd8grq returned 255 > > Cookbook Trace: > --------------- > /var/chef/cache/cookbooks/jenkins/libraries/_executor.rb:84:in > `execute!' > /var/chef/cache/cookbooks/jenkins/libraries/_executor.rb:137:in > `groovy!' > /var/chef/cache/cookbooks/jenkins/libraries/script.rb:48:in `block (2 > levels > ) in <class:JenkinsScript>' > /var/chef/cache/cookbooks/jenkins/libraries/script.rb:47:in `block in > <class > :JenkinsScript>' > > Resource Declaration: > --------------------- > # In /var/chef/cache/cookbooks/jenkins/recipes/plugins.rb > > 48: jenkins_script 'sonar' do > 49: command <<-EOH.gsub(/^ {4}/, '') > 50: import jenkins.model.* > 51: import hudson.plugins.sonar.* > 52: import hudson.plugins.sonar.model.* > 53: > 54: def inst =Jenkins.getInstance() > 55: > 56: > 57: def desc > =inst.getDescriptor("hudson.plugins.sonar.SonarPublisher") > 58: > 59: def sinst =new SonarInstallation( > 60: "sonar4.5.1", > 61: false, > 62: "http://localhost:9000/", > 63: "jdbc:mysql://localhost:3306/sonar", > 64: "com.mysql.jdbc.Driver", > 65: "sonar", > 66: "sonar", > 67: "", > 68: "", > 69: new TriggersConfig(), > 70: "admin", > 71: "admin" > 72: ) > 73: desc.setInstallations(sinst) > 74: > 75: desc.save() > 76: EOH > 77: > 78: end > 79: > > Compiled Resource: > ------------------ > # Declared in > /var/chef/cache/cookbooks/jenkins/recipes/plugins.rb:48:in `fr > om_file' > > jenkins_script("sonar") do > action [:execute] > retries 0 > retry_delay 2 > default_guard_interpreter :default > declared_type :jenkins_script > cookbook_name "jenkins" > recipe_name "plugins" > command "import jenkins.model.*\nimport > hudson.plugins.sonar.*\nimport hud > son.plugins.sonar.model.*\n\ndef inst =Jenkins.getInstance()\n\n\ndef desc > =inst > .getDescriptor(\"hudson.plugins.sonar.SonarPublisher\")\n\ndef sinst =new > SonarI > nstallation(\n \"sonar4.5.1\",\n false,\n \"http://localhost:9000/\",\n > \"jd > bc:mysql://localhost:3306/sonar\",\n \"com.mysql.jdbc.Driver\",\n > \"sonar\",\n > \"sonar\",\n \"\",\n \"\",\n new TriggersConfig(),\n \"admin\",\n > \"admin > \"\n)\ndesc.setInstallations(sinst)\n\ndesc.save()\n" > end > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c5b04be6-a8ee-43e1-a2b5-815c66a866f6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
