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

Active Choices plugin blocks using Jenkins.instance.getItemByFullName method from shared library

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • active-choices-plugin
    • None
    • Jenkins 2.346.3
      Plugin version 2.6.3
      Jenkins in k8s cluster (1.22.4)

      I have a helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

      Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

      I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

      Moving the helper function's code from shared library to Jenkinsfile solves the problem and the function returns a build object.

       

      Steps to reproduce:

      1. Create shared library with function from attachments.
      2. Create a pipeline which used this shared libarary.
      3. Add active choice paramter (I had 1 active choice and 1 active choice reactive parameters).
      4. Run pipeline and observe error "java.lang.NullPointerException: Cannot invoke method getDescription() on null object" in job's log.
      5. Remove reference to shared library and define function in pipeline instead.
      6. Run pipeline and observe build description in output.

      Attachments description:

        1. config.xml
          5 kB
        2. Jenkinsfile
          0.4 kB
        3. getBuildDescription.groovy
          0.3 kB

          [JENKINS-69328] Active Choices plugin blocks using Jenkins.instance.getItemByFullName method from shared library

          Valeriy Zabawski created issue -
          Valeriy Zabawski made changes -
          Description Original: I have helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.
          New: I have helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving helper function's code to Jenkinsfile solves the problem and function returns build object.
          Valeriy Zabawski made changes -
          Description Original: I have helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving helper function's code to Jenkinsfile solves the problem and function returns build object.
          New: I have a helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving the helper function's code from shared library to Jenkinsfile solves the problem and the function returns a build object.

          Does the behavior depend on the parameters of the pipeline that calls the helper function, or on the parameters of the job that Jenkins.instance.getItemByFullName should return?

          Kalle Niemitalo added a comment - Does the behavior depend on the parameters of the pipeline that calls the helper function, or on the parameters of the job that Jenkins.instance.getItemByFullName should return?
          Valeriy Zabawski made changes -
          Summary Original: Active Choices plugin blocks using Jenkins.instance.getItemByFullName method in pipeline New: Active Choices plugin blocks using Jenkins.instance.getItemByFullName method from shared library
          Valeriy Zabawski made changes -
          Description Original: I have a helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving the helper function's code from shared library to Jenkinsfile solves the problem and the function returns a build object.
          New: I have a helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving the helper function's code from shared library to Jenkinsfile solves the problem and the function returns a build object.

           

          Steps to reproduce:
           # Create shared library with function from attachments.
           # Create a pipeline which used this shared libarary.
           # Add active choice paramter (I had 1 active choice and 1 active choice reactive parameters).
           # Run pipeline and observe error "java.lang.NullPointerException: Cannot invoke method getDescription() on null object" in job's log.
           # Remove reference to shared library and define function in pipeline instead.
           # Run pipeline and observe build description in output.
          Valeriy Zabawski made changes -
          Attachment New: Jenkinsfile [ 58743 ]
          Valeriy Zabawski made changes -
          Environment Original: Jenkins 2.346.3
          Plugin version 2.6.3
          New: Jenkins 2.346.3
          Plugin version 2.6.3
          Jenkins in k8s cluster (1.22.4)
          Valeriy Zabawski made changes -
          Attachment New: config.xml [ 58744 ]
          Valeriy Zabawski made changes -
          Description Original: I have a helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving the helper function's code from shared library to Jenkinsfile solves the problem and the function returns a build object.

           

          Steps to reproduce:
           # Create shared library with function from attachments.
           # Create a pipeline which used this shared libarary.
           # Add active choice paramter (I had 1 active choice and 1 active choice reactive parameters).
           # Run pipeline and observe error "java.lang.NullPointerException: Cannot invoke method getDescription() on null object" in job's log.
           # Remove reference to shared library and define function in pipeline instead.
           # Run pipeline and observe build description in output.
          New: I have a helper function in shared library which retrieves build description by job name and build number. When I add active choice parameters to Jenkins pipeline, this function stops working, Jenkins.instance.getItemByFullName returns null.

          Removing Active choice parameters restores the functionality and Jenkins.instance.getItemByFullName returns build object.

          I've tried enabling and disabling sandbox for Active Choice paramters' scripts, but it doesn't change the situation.

          Moving the helper function's code from shared library to Jenkinsfile solves the problem and the function returns a build object.

           

          Steps to reproduce:
           # Create shared library with function from attachments.
           # Create a pipeline which used this shared libarary.
           # Add active choice paramter (I had 1 active choice and 1 active choice reactive parameters).
           # Run pipeline and observe error "java.lang.NullPointerException: Cannot invoke method getDescription() on null object" in job's log.
           # Remove reference to shared library and define function in pipeline instead.
           # Run pipeline and observe build description in output.

          Attachments description:
           * Function source code which used in shared library: [^getBuildDescription.groovy]
           * Jenkinsfile (pipeline code used in job): [^Jenkinsfile]
           * Job with parameters and pipeline code (Jenkinfile duplicates pipeline code): [^config.xml]

            kinow Bruno P. Kinoshita
            dziki_jam Valeriy Zabawski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: