Thank you Dirk, for pointing me the right direction, but let me hopefully
ask a final question:
Is there a way to execute this tiny groovy-script, which runs in the script
console without errors, within a Jenkins job?
I tried it with using "Execute system Groovy script, which brings up this
error:
ERROR: Build step failed with exception
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts
not permitted to use staticMethod jenkins.model.Jenkins getInstance
at
org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectStaticMethod(StaticWhitelist.java:189)
at
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onStaticCall(SandboxInterceptor.java:160)
at org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:186)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:190)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:97)
at
org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at Script1.run(Script1.groovy:4)
at
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:141)
at
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:333)
at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1727)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Build step 'Execute system Groovy script' marked build as failure
Finished: FAILURE
and as "Execute Groovy Script" with the error i posted before. "I can't see
the wood, as there are too many trees"...
Yours
Volker
Am Mittwoch, 4. April 2018 13:36:23 UTC+2 schrieb Volker Groß:
>
> Hi,
>
> i'm having a bunch of groovy-scripts, which are at least about 2,5 years
> old. At the time the scripts where set up, we were able to add
> publish-over-ssh ssh-servers within the jenkins global configuration tab.
> After one update those scripts won't run again. I'm always getting this
> error:
>
> Started by user Entwicklung
> [EnvInject] - Loading node environment variables.
> Building in workspace /var/lib/jenkins/workspace/DSL-Global-Credentials
> Processing provided DSL script
> ERROR: startup failed:
> script: 33: unable to resolve class BapSshHostConfiguration
> @ line 33, column 23.
> def configuration = new
> BapSshHostConfiguration(host[0],host[1],host[2],host[3],host[4],host[5],host[6],host[7],host[8],host[9],host[10])
> ^
>
> 1 error
>
> Finished: FAILURE
>
> This is my script, i just deleted the host-values ;)
>
> import jenkins.model.*
> import jenkins.plugins.publish_over_ssh.BapSshHostConfiguration
>
> def inst = Jenkins.getInstance()
> def publish_ssh =
> inst.getDescriptor('jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin')
>
>
> println
> "############################################################################################################"
> println "PublishOverSsh - Creating global list of Server/Paths"
> println
> "############################################################################################################"
>
>
> /* Serverlist
> The following has to be set.
>
> name,hostname,username,encryptedPassword,remoteRootDir,port,timeout,overrideKey,keyPath,key,disableExec
> */
> def hosts = [
>
> ['Hostalias','hostname','user','encryptedPassword','remoteRootDir',22,30000,false,'','',true]
> ]
>
> println 'Renewing Global Publish-Over-SSH-Server Configs'
>
> hosts.each { host->
> def configuration = new
> BapSshHostConfiguration(host[0],host[1],host[2],host[3],host[4],host[5],host[6],host[7],host[8],host[9],host[10])
> println " - SSH-Host ${host[0]}"
> publish_ssh.removeHostConfiguration(host[0])
> publish_ssh.addHostConfiguration(configuration)
> }
>
> I hope one can help.
>
> Best from DE
> Volker
>
--
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/b89358de-9ab8-470f-93a0-6b3b899db1c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.