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

Fail evaluating Groovy script before job run

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I try to inject last successfull build revision into env vars with Groovy script. It runs successfully in Jenkins execution console, but fails inside job run(Mercurial plugin need to be installed.)

      [jenkins] $ cmd /c call C:\Windows\TEMP\hudson5593478547391954761.bat
      C:\Dev\HG\jenkins>exit 0
      [EnvInject] - Script executed successfully.
      [EnvInject] - Evaluation the following Groovy script content:
      import hudson.plugins.mercurial.MercurialTagAction

      def lastStableBuild = Jenkins.instance.getItem($JOB_NAME).getLastStableBuild()
      if (lastStableBuild == null)

      { return null; }

      def mercurialAction = lastStableBuild.getAction(MercurialTagAction)
      if (mercurialAction == null){ return null; }

      def lastSuccessRev = [LAST_SUCCESS_REVISION: mercurialAction.getRev()]
      return lastSuccessRev

      [EnvInject] - [ERROR] - SEVERE ERROR occurs: startup failed:
      Script1.groovy: 1: unable to resolve class hudson.plugins.mercurial.MercurialTagAction
      @ line 1, column 1.
      import hudson.plugins.mercurial.MercurialTagAction
      ^

      1 error

        Attachments

          Activity

          Hide
          gbois Gregory Boissinot added a comment -

          At the moment, the classpath for the Groovy script doesn't use the installed plugins. It is why it doesn't know the MercurialTagAction class from the mercurial plugin. I need to look at how to fix it.

          Show
          gbois Gregory Boissinot added a comment - At the moment, the classpath for the Groovy script doesn't use the installed plugins. It is why it doesn't know the MercurialTagAction class from the mercurial plugin. I need to look at how to fix it.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java
          http://jenkins-ci.org/commit/envinject-plugin/65eeb2db05129460643fa95b78f61b0216d1c054
          Log:
          Fix JENKINS-14686

          Compare: https://github.com/jenkinsci/envinject-plugin/compare/f3c682e863b4...65eeb2db0512

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java http://jenkins-ci.org/commit/envinject-plugin/65eeb2db05129460643fa95b78f61b0216d1c054 Log: Fix JENKINS-14686 Compare: https://github.com/jenkinsci/envinject-plugin/compare/f3c682e863b4...65eeb2db0512
          Hide
          gbois Gregory Boissinot added a comment -

          Please could you check if the new build jenkins plugin fix the issue
          https://buildhive.cloudbees.com/job/jenkinsci/job/envinject-plugin/ws/target/envinject.hpi ?

          Thanks

          Show
          gbois Gregory Boissinot added a comment - Please could you check if the new build jenkins plugin fix the issue https://buildhive.cloudbees.com/job/jenkinsci/job/envinject-plugin/ws/target/envinject.hpi ? Thanks
          Hide
          advantiss Peter S added a comment -

          Thanks for quick response and fast resolving. Bug fixed

          Show
          advantiss Peter S added a comment - Thanks for quick response and fast resolving. Bug fixed

            People

            • Assignee:
              gbois Gregory Boissinot
              Reporter:
              advantiss Peter S
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: