Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29073

Groovy script works in script console fails as Global Post Script

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • Jenkins 1.609.1,
      Claim plugin: 2.7
      Global post script plugin: 1.0.10

      I want to get claim reason in the script

      job = hudson.model.Hudson.instance.getItem("demo2")
      build = job.getLastBuild()
      println build
      def action = build.getAction(hudson.plugins.claim.ClaimBuildAction.class)
      print action.getReason()
      

      The script works well under jenkins script console (/script), while when it is executed as global post script, it reports

      Failed to execute: claim.groovy, No such property: hudson for class: Script1

      in build.getAction(), it seems I can't pass the class name inside.

            orctom Hao CHEN
            orctom Hao CHEN
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: