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

Builds failure triggered via Poll SCM when execute a system groovy script.

XMLWordPrintable

      Builds are not triggered via Poll SCM.
      This error is solved when server is restart.

      ERROR: Build step failed with exception
      java.lang.IllegalArgumentException: Null value not allowed as an environment variable: REPOVERSION
      	at hudson.EnvVars.put(EnvVars.java:356)
      	at hudson.model.StringParameterValue.buildEnvironment(StringParameterValue.java:56)
      	at hudson.model.ParametersAction.buildEnvVars(ParametersAction.java:89)
      	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:953)
      	at hudson.plugins.gradle.Gradle.performTask(Gradle.java:127)
      	at hudson.plugins.gradle.Gradle.perform(Gradle.java:118)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
      	at hudson.model.Build$BuildExecution.build(Build.java:205)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:162)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
      	at hudson.model.Run.execute(Run.java:1741)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:408)
      Build step 'Invoke Gradle script' marked build as failure
      ERROR: Failed to evaluate groovy script.
      java.lang.IllegalArgumentException: Null value not allowed as an environment variable: REPOVERSION
      	at hudson.EnvVars.put(EnvVars.java:356)
      	at hudson.model.StringParameterValue.buildEnvironment(StringParameterValue.java:56)
      	at hudson.model.ParametersAction.buildEnvVars(ParametersAction.java:89)
      	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:953)
      	at hudson.model.AbstractBuild$getEnvironment.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at notifybuild.run(notifybuild.groovy:12)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:627)
      	at groovy.lang.Script.evaluate(Script.java:219)
      	at groovy.lang.Script$evaluate.callCurrent(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      	at Script1.run(Script1.groovy:1)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
      	at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:276)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
      	at hudson.model.Build$BuildExecution.post2(Build.java:185)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
      	at hudson.model.Run.execute(Run.java:1766)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:408)
      Build step 'Groovy Postbuild' marked build as failure
      

      Version of Jenkins this bug is occurring

      Jenkins ver. 1.625.3
      

      Version of groovy plugin

      ver. 1.14
      

      Version of groovy postbuild plugin

      ver. 1.8
      

      Groovy script

      import groovyx.net.http.RESTClient
      import static groovyx.net.http.ContentType.*
      import hudson.model.*
      
      def repoversion = "X"
      def env = build.getEnvironment()
      def projectName = build.project.getName()
      def commit = env['GIT_COMMIT']
      int CONNECTION_TIMEOUT  = 30*1000;
       int SOCKET_TIMEOUT = 45*1000;
      
      try{
       def solnet = new RESTClient( 'http://ip_adress/' )
       solnet.getClient().getParams().setParameter("http.connection.timeout", new Integer(CONNECTION_TIMEOUT))
       solnet.getClient().getParams().setParameter("http.socket.timeout", new Integer(SOCKET_TIMEOUT))
      
       def resp = solnet.get( path : 'repo_get_version.php', query: ['name':projectName,'revision':commit])
       if(resp.status == 200){
        repoversion = resp.data.version
       }
      }
      catch(Exception e){
         println e.getMessage()
      }
      
      def pa = new ParametersAction([
        new StringParameterValue("REPOVERSION", repoversion)
      ])
      
      // add variable to current job
      Thread.currentThread().executable.addAction(pa)
      

            vjuranek vjuranek
            andres123 Andres Garcia
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: