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

Groovy script works in script console fails as Global Post Script

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Duplicate
    • None
    • Jenkins 1.609.1,
      Claim plugin: 2.7
      Global post script plugin: 1.0.10

    Description

      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.

      Attachments

        Activity

          orctom Hao CHEN added a comment -

          wrong component

          orctom Hao CHEN added a comment - wrong component

          People

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

            Dates

              Created:
              Updated:
              Resolved: