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

The Pipeline load statement returns Null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • pipeline
    • None

      I try to load a simple groovy script inside my pipeline definition.
      The following is my Jenkins-Pipeline-Script:

      def flow

      stage(name: "Fetch groovy script from SCM")
      {
      node("master")
      {
      ws('C:\\Jenkins\\jobs\\BuildJobs\\jobs\\Build_Test
      workspace')
      { flow = load 'build.groovy' println(flow) }
      }
      }

      flow.execute()

      It loads the script C:\Jenkins\jobs\BuildJobs\jobs\Build_Test\workspace\build.groovy on the master node:


      def execute()
      {
      stage (name:"Print ReleaseTypes")
      {
      node("master")
      { echo releaseType }
      }
      }

      return this

      If I execute the pipeline job, I get the following result:


      [Pipeline] stage
      [Pipeline] { (Fetch groovy script from SCM)
      [Pipeline] node
      Running on master in C:\jenkins\jobs\BuildJobs\jobs\Build_Test\workspace
      [Pipeline] {
      [Pipeline] ws
      Running in C:\Jenkins\jobs\BuildJobs\jobs\Build_Test\workspace
      [Pipeline] {
      [Pipeline] load
      [Pipeline] { (build.groovy) [Pipeline] }
      [Pipeline] // load
      [Pipeline] echo
      null
      [Pipeline] }
      [Pipeline] // ws
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      [BFA] Scanning build for known causes...
      [BFA] No failure causes found
      [BFA] Done. 0s
      java.lang.NullPointerException: Cannot invoke method execute() on null object

      I use the lates Jenkins (Jenkins ver. 2.26)

            Unassigned Unassigned
            florianreiser Florian Reiser
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: