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

groovy date arithmetics do not work in pipeline

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • workflow-cps-plugin
    • None
    • Jenkins 2.7.4
      Pipeline suite plugin 2.4

      Hi,

      The following date/time arithemetics which work in groovy - do not work in a pipeline script:

      import groovy.time.*
      def startDate = new Date()
      def timeout = startDate  + 1.hours //increment 1 hour
      

      use( TimeCategory ) doesn't help.

      I get the following error:
      groovy.lang.MissingPropertyException: No such property: hours for class: java.lang.Integer

      I also wasn't able to find any workaround for this - I was only able to increment integers (as in days)

          [JENKINS-40154] groovy date arithmetics do not work in pipeline

          Mor L created issue -
          Mor L made changes -
          Description Original: Hi,

          The following date/time arithemetics which work in groovy - do not work in a pipeline script:

          {code:java}
          import groovy.time.*
          def startDate = new Date()
          def timeout = startDate + 1.hours //increment 1 hour
          {code}

          I get the following error:
          groovy.lang.MissingPropertyException: No such property: hours for class: java.lang.Integer
          New: Hi,

          The following date/time arithemetics which work in groovy - do not work in a pipeline script:

          {code:java}
          import groovy.time.*
          def startDate = new Date()
          def timeout = startDate + 1.hours //increment 1 hour
          {code}

          I get the following error:
          groovy.lang.MissingPropertyException: No such property: hours for class: java.lang.Integer

          I also wasn't able to find any workaround for this - I was only able to increment integers (as in days)
          Mor L made changes -
          Description Original: Hi,

          The following date/time arithemetics which work in groovy - do not work in a pipeline script:

          {code:java}
          import groovy.time.*
          def startDate = new Date()
          def timeout = startDate + 1.hours //increment 1 hour
          {code}

          I get the following error:
          groovy.lang.MissingPropertyException: No such property: hours for class: java.lang.Integer

          I also wasn't able to find any workaround for this - I was only able to increment integers (as in days)
          New: Hi,

          The following date/time arithemetics which work in groovy - do not work in a pipeline script:

          {code:java}
          import groovy.time.*
          def startDate = new Date()
          def timeout = startDate + 1.hours //increment 1 hour
          {code}

          use( TimeCategory ) doesn't help.

          I get the following error:
          groovy.lang.MissingPropertyException: No such property: hours for class: java.lang.Integer

          I also wasn't able to find any workaround for this - I was only able to increment integers (as in days)
          Andrew Bayer made changes -
          Component/s New: workflow-cps-plugin [ 21713 ]
          Component/s Original: pipeline [ 21692 ]

            Unassigned Unassigned
            pyrocks Mor L
            Votes:
            8 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: