I want to get Getting current timestamp in inline pipeline script using pipeline plugin of hudson. For setting up build display name.
Inline groovy script used:
def jobName = env.JOB_NAME + "_" + new Date() currentBuild.displayName = "$jobName" node { echo "job name $jobName" }
Error on console :
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new java.util.Date
To create a simple pipeline from the Jenkins interface, perform the following steps: Click New Item on your Jenkins home page, enter a name for your (pipeline) job, select Pipeline, and click OK. In the Script text area of the configuration screen, enter your pipeline syntax.
you can also use this, I needed this in ms so:
echo "TimeStamp: ${currentBuild.startTimeInMillis}" echo "TimeStamp: ${Util.getTimeSpanString(System.currentTimeMillis())}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With