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

sh execution returns to pipeline

XMLWordPrintable

      We are Working on a Scripted Pipeline managed with SCM.
      Currently we are calling Class-Methods from the Pipeline to keep the code clean and Object orientated.

      The Problem we encounter is that every Time we call the `sh` command the whole Body after that call will be skipped and the current state will return to the pipeline. This would be as follows:

      pipeline.groovy
      ...
      ums = new UmsHandler(this)
      ums.getSessionID()
      UmsHandler.groovy
      UmsHandler(steps) {
        this.steps = steps
      }
      
      @NonCPS
      String getSessionID() {
        def exitcode = steps.sh(script: "getSessionID", returnStatus: true)
        if (exitcode != 0) {
          foo
        }
      }
      

      every Time we execute the command (and it is executed we log that on the Machine) the code after that execution won't be executed. The Script will return to the pipeline and proceed there.

      I'm not sure if this is the correct way to execute a Command from a Class or even if this behavior is expected, but I would appropriate a Solution to this Problem.

            Unassigned Unassigned
            biskit1943 Maximilian Konter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: