diff --git a/rundeckapp/grails-app/services/rundeck/services/ExecutionService.groovy b/rundeckapp/grails-app/services/rundeck/services/ExecutionService.groovy index e944e929a0b..10dae03611c 100644 --- a/rundeckapp/grails-app/services/rundeck/services/ExecutionService.groovy +++ b/rundeckapp/grails-app/services/rundeck/services/ExecutionService.groovy @@ -1530,14 +1530,27 @@ class ExecutionService implements ApplicationContextAware, StepExecutor, NodeSte def Execution execution = createExecution(props) execution.dateStarted = new Date() - if(execution.argString =~ /\$\{DATE:(.*)\}/){ + if(execution.argString =~ /\$\{DATE(.*)\}/){ def newstr = execution.argString - try{ - newstr = execution.argString.replaceAll(/\$\{DATE:(.*)\}/,{ all,tstamp -> - new SimpleDateFormat(tstamp).format(execution.dateStarted) + try { + newstr = execution.argString.replaceAll(/\$\{DATE(.*?)\}/, { all, tstamp -> + if(tstamp.lastIndexOf(":") == -1){ + return all + } + final operator = tstamp.substring(0, tstamp.lastIndexOf(":")) + final fdate = tstamp.substring(tstamp.lastIndexOf(":")+1) + if(operator == ''){ + new SimpleDateFormat(fdate).format(execution.dateStarted) + }else{ + final number = operator as int + final newDate = execution.dateStarted +number + new SimpleDateFormat(fdate).format(newDate) + } }) - }catch(IllegalArgumentException e){ + } catch (IllegalArgumentException e) { + log.warn(e) + } catch (NumberFormatException e){ log.warn(e) } @@ -1718,15 +1731,28 @@ class ExecutionService implements ApplicationContextAware, StepExecutor, NodeSte Execution execution = createExecution(props) execution.dateStarted = new Date() - if (execution.argString =~ /\$\{DATE:(.*)\}/) { + if (execution.argString =~ /\$\{DATE(.*)\}/) { def newstr = execution.argString try { - newstr = execution.argString.replaceAll(/\$\{DATE:(.*)\}/, { all, tstamp -> - new SimpleDateFormat(tstamp).format(execution.dateStarted) + newstr = execution.argString.replaceAll(/\$\{DATE(.*?)\}/, { all, tstamp -> + if(tstamp.lastIndexOf(":") == -1){ + return all + } + final operator = tstamp.substring(0, tstamp.lastIndexOf(":")) + final fdate = tstamp.substring(tstamp.lastIndexOf(":")+1) + if(operator == ''){ + new SimpleDateFormat(fdate).format(execution.dateStarted) + }else{ + final number = operator as int + final newDate = execution.dateStarted +number + new SimpleDateFormat(fdate).format(newDate) + } }) } catch (IllegalArgumentException e) { log.warn(e) + } catch (NumberFormatException e){ + log.warn(e) }