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

Input step breaks out of global library

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • None
    • Jenkins 2.71
      Pipeline: Shared Groovy Libraries 2.3

      If I have global library in vars/myGlobalLibrary.groovy and inside of that I ask for an input step, the input step breaks out of the method.

      You'll see that the methods right after the def userInput = input are not executed.

      The methods inside my pipeline after the call to the global library are executed so it isn't killing the whole pipeline, just breaking out of the global method release().

      If the call to input is moved back out into the pipeline itself it works just fine and captures the response in the userInput variable.

      Essentially I'm trying to use the global libraries to make my pipeline much shorter and in this case I'm trying to call out to steps like input inside that global var.

      vars/myGlobalLibrary.groovy

      @NonCPS
      def release() {
      
          def userInput = input(
              id: 'userInput', 
              message: 'Proceed with release?', 
              parameters: [
                  [$class: 'TextParameterDefinition', defaultValue: "1.0", description: 'Release Version', name: 'releaseVersion']
              ])
      
      
          echo "never gets here"
      
          echo "releaseversion: " + userInput['releaseversion']
      }
      

      My pipeline stage:

      @Library('pipelinehelper@master') _
          
      deployToProdStage()
      
      def deployToProdStage() {
          stage name:'PROD Deploy',concurrency: 1
      
          myGlobalLibrary.release()
          echo "Makes it here just fine"
      }
      

            jglick Jesse Glick
            kenneth_s_brooks Kenneth Brooks
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: