Advertisement
METAJIJI

Jenkins pipeline: @NonCPS

Aug 11th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.82 KB | None | 0 0
  1. import com.cloudbees.groovy.cps.NonCPS
  2. import jenkins.model.*
  3. import hudson.model.Result
  4.  
  5. @NonCPS
  6. def getProject(projectName) {
  7.     // CloudBees folder plugin is supported, you can use natural paths:
  8.     // in a postbuild action use `manager.hudson`
  9.     // in the script web console use `Jenkins.instance`
  10.     def project = jenkins.model.Jenkins.instance.getItemByFullName(projectName)
  11.     if (!project) {error("Project not found: $projectName")}
  12.     return project
  13. }
  14.  
  15. project = getProject('foo/bar')
  16. build = project.getBuildByNumber(2443)  // build = project.getBuild(project, '2443')
  17.  
  18. build.@result = hudson.model.Result.SUCCESS
  19. // build.@result = hudson.model.Result.NOT_BUILT
  20. // build.@result = hudson.model.Result.UNSTABLE
  21. // build.@result = hudson.model.Result.FAILURE
  22. // build.@result = hudson.model.Result.ABORTED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement