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

Scripted Pipeline does not work due to tags

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • rundeck-plugin
    • Jenkins V2.138
      Rundeck V2.9.3-1
      Rundeck-plugin V3.6.4

      Hello,

      There is bug in the constructor of RundeckNotifier. 

      When we declare a scripted pipeline like below, we get this exception "Caused by: java.lang.ClassCastException: org.jenkinsci.plugins.rundeck.RundeckNotifier.tags expects class java.lang.String but received class java.util.ArrayList".

      stage('Deploy Release') { 
        steps { 
          script { 
            step([$class: "RundeckNotifier", 
                  includeRundeckLogs: true, 
                  jobId: "1", 
                  rundeckInstance: "rundeck", 
                  shouldFailTheBuild: true, 
                  shouldWaitForRundeckJob: true, 
                  tailLog: true]) 
            } 
          } 
        }
      }

       

      In RundeckNotifier class, the constructor annotated by "@DataBoundConstructor" contains a parameter called "tags". Jenkins Structs plugin get the name of fields that can be declared in the pipeline thanks to this constructor and after the plugin get the type of fields declared as attribute of class.

      Two attributes are declared in the RundeckNotifier class: String tag and String [] tags.

      The plugin get "tags" as parameter of contructor (declare as String in constructor) and get the type "String[]" from class attribute. So the mapping is in failure because the field "tags" is declared as String[] in class but it's declared as String in the constructor.

      On my own environment, I have fixed this issue by renaming the field from "tags" to "tag" in the annotated constructor and it works well.

       

            vbehar Vincent Behar
            csarre Cédric SARRE
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: