Pasha
Pasha

Reputation: 190

Jenkins groovy post build action plugin issue

Following code is to find a job in Jenkins and for that job find a required build and addsummary using groovy post build plugin.

def r = jenkins.model.Jenkins.instance.getAllItems().findAll { it.name.contains("<myjob>") }

r.each { t ->
  def builds = t.getBuilds()
  builds.each{ b ->
  if(b.displayName == '<myversion>'){
    manager.createSummary("success.gif").appendText("<h1>Hello!!</h1>", false, false, false, "black")
      }
      b.save()
    }
  }

its failing with following error..

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method java.lang.Class createSummary java.lang.String
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:113)

Upvotes: 1

Views: 938

Answers (2)

Suresh
Suresh

Reputation: 750

The Groovy code which you are using should be whitelisted or approved.

It is clear from the error message the code is not approved.

For further information go through this link Script Security Plugin.

Go to Manage Jenkins » In-process Script Approval where a list of scripts pending approval will be shown.

Upvotes: 0

VonC
VonC

Reputation: 1328712

You need to go to Jenkins -> Manage Jenkins -> In-process Script Approval.
(From the JENKINS Script Security Plugin)

You will be able to approve that signature there.

See a full example at "Jenkins Groovy Script Approval"

https://cdn-images-1.medium.com/max/1600/1*RQvhikivuJ5526FDNd15lA.png

Upvotes: 1

Related Questions