Assignment in if statements does not work

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      The following fails in pipeline scripts (the if statement always evaluates to false)

      def getStatus(){
       // ....
       "Ready"
      }
      
      //....
      
      
      def acceptedStatuses = ["Ready", "Updated", "Failed" ]
      def status
      if(acceptedStatuses.contains((status = getStatus()))){
         // never called
      }
      
      
      

            Assignee:
            Unassigned
            Reporter:
            Zhelyan Panchev
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: