I am using the shell script to get current time of the build in Jenkins agent. This is being run in docker image node:alpine This command works:
def BUILDVERSION = sh(script: "echo `date +%Y-%m-%d-%H-%M-%S`", returnStdout: true).trim()
Output: 2021-11-20-15-27-57
Now I want to add 1 hour to the time value so I modified my script with -d '+1 hour'
This shell script works in Linux in general, but if I use it on Jenkins build agent I am getting the message: invalid date '+1 hour'
This is the script which does not work!
def BUILDVERSION = sh(script: "echo `date -d '+1 hour' +%Y-%m-%d-%H-%M-%S`", returnStdout: true).trim()
Thanks for assistance!