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

Docker, Declarative Pipeline, Shared Library sh call hangs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None

      Following the examples and Youtube videos on the Jenkins shared-library wiki, I created and loaded a Global Shared Library into my project, which is using Declarative Pipelines. I know that it's working because another script call in the pipeline is already working (one that uses the SCM commands to check out my code).

      However, I'm trying to run a shell script, and the process hangs for 5 minutes, then times out. The error I see in the log is:

      [Pipeline] sh
      process apparently never started in /var/jenkins_home/workspace/MY-PROJECT@tmp/durable-f178948e
      (running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
      [Pipeline] }

      I did set the LAUNCH_DIAGNOSTICS to true, and get the following:

      sh: 1: cannot create /var/jenkins_home/workspace/MY-PROJECT@tmp/durable-404b95e3/jenkins-log.txt: Directory nonexistent
      sh: 1: cannot create /var/jenkins_home/workspace/MY-PROJECT@tmp/durable-404b95e3/jenkins-result.txt.tmp: Directory nonexistent
      mv: cannot stat '/var/jenkins_home/workspace/MY-PROJECT@tmp/durable-404b95e3/jenkins-result.txt.tmp': No such file or directory

      EDIT: Just to add to this, I pulled the "sh" command out of the shared library and into the pipeline. "sh" in steps hangs forever (even on just a simple "ls" command), but echo does not (e.g. echo "Hello World!" works as expected).

      Pipeline:

      @Library("jenkinsSharedLibraries@Groovy-sh-scripts") _
      pipeline
      {
          agent
          {
              docker 
              { 
                  image 'build-image'
                  args ''
              }
          }
          stages
          {
              stage('Checkout')
              {
                  steps
                  {
                      sparseCheckoutBranch([branch: "MY-PROJECT", credentialsId: "jenkins-credentials"])
                      testScript()
                  }
              }
          }
      }

      sparseCheckoutBranch:

      #!/usr/bin/env groovy
      
      def call(Map params = [:])
      {
      
        checkout([$class: 'SubversionSCM',
          additionalCredentials: [],
          excludedCommitMessages: '',
          excludedRegions: '',
          excludedRevprop: '',
          excludedUsers: '',
          filterChangelog: false,
          ignoreDirPropChanges: false,
          includedRegions: '',
          locations: [
            [
              remote: "https://myserver.com/svn/${params.branch}",
              local: "${params.branch}",
              depthOption: 'files',
              credentialsId: "${params.credentialsId}"
            ],
            [
              remote: "https://myserver.com/svn/${params.branch}/env",
              local: "${params.branch}/env",
              depthOption: 'infinity',
              credentialsId: "${params.credentialsId}"
            ]
          ],
          quietOperation: false,
          workspaceUpdater: [$class: 'UpdateWithCleanUpdater']
        ])
      
      }
      

      testScript:

      #!/usr/bin/env groovy
      
      def call()
      {
        sh "echo Hello World!"
      }
      

       

            csanchez Carlos Sanchez
            zlacelle Zach LaCelle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: