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. getBuildDescription.groovy
          0.3 kB
        3. Jenkinsfile
          0.4 kB

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

          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 added a comment - - edited

          Parameters does not use shared library. They just retrieve values which are later passed to the helper function. I've attached job config.xml for better understanding of my setup.

          Valeriy Zabawski added a comment - - edited Parameters does not use shared library. They just retrieve values which are later passed to the helper function. I've attached job config.xml for better understanding of my setup.

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

              Created:
              Updated: