[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Renzo Crisóstomo edited a comment on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline fyi: You can move this code to a Jenkins Pipeline shared library and add a @NonCPS decorator to it to avoid this kind of sandbox problems: { { noformat} @NonCPSdef call(Date startDate, Date endDate) {use(groovy.time.TimeCategory) {def duration = endDate - startDatereturn duration.days}} {noformat } } Extending with Shared Libraries: [https://jenkins.io/doc/book/pipeline/shared-libraries/] Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Renzo Crisóstomo edited a comment on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline fyi: You can move this code to a Jenkins Pipeline shared library and add a @NonCPS decorator to it to avoid this kind of sandbox problems: {{ @NonCPSdef call(Date startDate, Date endDate) {use(groovy.time.TimeCategory) {def duration = endDate - startDatereturn duration.days}} }} Extending with Shared Libraries: [https://jenkins.io/doc/book/pipeline/shared-libraries/] Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Renzo Crisóstomo edited a comment on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline fyi: You can move this code to a Jenkins Pipeline shared library and add a @NonCPS decorator to it to avoid this kind of sandbox problems: {{ @NonCPSdef call(Date startDate, Date endDate) {use(groovy.time.TimeCategory) {def duration = endDate - startDatereturn duration.days}} }} Extending with Shared Libraries: [https://jenkins.io/doc/book/pipeline/shared-libraries/] Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Renzo Crisóstomo edited a comment on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline fyi: You can move this code to a Jenkins Pipeline shared library and add a @NonCPS decorator to it to avoid this kind of sandbox problems: {{ ``` @NonCPS def call(Date startDate, Date endDate) { use(groovy.time.TimeCategory) { def duration = endDate - startDate return duration.days } } } } ``` Extending with Shared Libraries: [https://jenkins.io/doc/book/pipeline/shared-libraries/] Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Renzo Crisóstomo edited a comment on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline fyi: You can move this code to a Jenkins Pipeline shared library and add a @NonCPS decorator to it to avoid this kind of sandbox problems: ```@NonCPSdef call(Date startDate, Date endDate) { use(groovy.time.TimeCategory) { def duration = endDate - startDate return duration.days } }``` Extending with Shared Libraries: [ https://jenkins.io/doc/book/pipeline/shared-libraries/ ] Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Renzo Crisóstomo commented on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline fyi: You can move this code to a Jenkins Pipeline shared library and add a @NonCPS decorator to it to avoid this kind of sandbox problems: ``` @NonCPS def call(Date startDate, Date endDate) { use(groovy.time.TimeCategory) { def duration = endDate - startDate return duration.days } } ``` Extending with Shared Libraries: https://jenkins.io/doc/book/pipeline/shared-libraries/ Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Sergey Galkin commented on JENKINS-40154 Re: groovy date arithmetics do not work in pipeline The same picture almost The code import groovy.time.TimeCategory now = new Date() use(TimeCategory) { ydate = now - 1.days } is working fine but in one perfect day stop working with error Started by timer [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: days for class: java.lang.Integer Possible solutions: class at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:33) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) at WorkflowScript.run(WorkflowScript:4) at WorkflowScript.run(WorkflowScript:3) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66) at sun.reflect.GeneratedMethodAccessor1794.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:58) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Finished: FAILURE
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Mor L updated an issue Jenkins / JENKINS-40154 groovy date arithmetics do not work in pipeline Change By: Mor L 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.IntegerI also wasn't able to find any workaround for this - I was only able to increment integers (as in days) Add Comment This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Mor L updated an issue Jenkins / JENKINS-40154 groovy date arithmetics do not work in pipeline Change By: Mor L 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) Add Comment This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-40154) groovy date arithmetics do not work in pipeline
Title: Message Title Mor L created an issue Jenkins / JENKINS-40154 groovy date arithmetics do not work in pipeline Issue Type: Bug Assignee: Unassigned Components: pipeline Created: 2016/Dec/01 2:45 PM Environment: Jenkins 2.7.4 Pipeline suite plugin 2.4 Priority: Major Reporter: Mor L 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 I get the following error: groovy.lang.MissingPropertyException: No such property: hours for class: java.lang.Integer Add Comment