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

Referencing a vars implicit property that is not set causes build to hang forever

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Using Jenkins 2.19.2.

      I'm trying to construct a shared library that can save params and global variables,with methods that can reference those variables. I'm building this step by step to make sure all the pieces work.

      I have this skeleton at this point:

      def setCurrentBuild(value) { currentBuild	= value; }
      def getCurrentBuild() { return currentBuild }
      
      def setJobName(value) { jobName	= value; }
      def getJobName() { return jobName }
      
      def setBuildURL(value) { buildURL = value; }
      def getBuildURL() { return buildURL }
      
      def setMechIdCredentials(value) { mechIdCredentials = value; }
      def getMechIdCredentials() { return mechIdCredentials }
      
      String toString() {
      	echo "Inside uslutils.toString()."
      	return "[currentBuild[${currentBuild}] jobName[${jobName}] buildURL[${buildURL}] mechIdCredentials[${mechIdCredentials}]"
      }
      

      And it's referenced from this Jenkinsfile:

      @Library("usl-pipeline-library@master")
      import com.att.usl.jenkins.BUILD_STATUS
      
      node {
          stage ("first") {
              uslutils.currentBuild   = currentBuild
              uslutils.jobName        = env.JOB_NAME
      	uslutils.buildURL       = env.BUILD_URL
      			
      	println "uslutils.toString()[${uslutils.toString()}]"
          }
      }
      

      I also have the following in "src":

      package com.att.usl.jenkins
      
      enum BUILD_STATUS {
      	IN_PROGRESS, SUCCESS, FAILED
      }
      

      When I run this Jenkinsfile, it hangs forever on the call to "toString()". I had to abort the build to get it to complete.

      I then changed the block above to this:

              uslutils.currentBuild   = currentBuild
              uslutils.jobName        = env.JOB_NAME
      	uslutils.buildURL       = env.BUILD_URL
      	uslutils.mechIdCredentials = "abc"
      

      And then I reran the build, and it completed successfully.

      Generally, all the parameters will be set, but I need a more robust solution for dealing with this situation.

        Attachments

          Issue Links

            Activity

            Hide
            orrc Christopher Orr added a comment -

            AFAICT, this is a duplicate of JENKINS-31484.

            If the (implicit) uslutils.mechIdCredentials variable is not set, then trying to resolve the GString ${mechIdCredentials} will call the getMechIdCredentials() method, which will then call itself trying to return mechIdCredentials, so you end up in an infinite loop.

            Show
            orrc Christopher Orr added a comment - AFAICT, this is a duplicate of JENKINS-31484 . If the (implicit) uslutils.mechIdCredentials variable is not set, then trying to resolve the GString ${mechIdCredentials } will call the getMechIdCredentials() method, which will then call itself trying to return mechIdCredentials , so you end up in an infinite loop.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              dkarr David Karr
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: