Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting current timestamp in inline pipeline script using pipeline plugin of hudson

Tags:

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 
like image 272
Goutham Nithyananda Avatar asked Oct 26 '16 11:10

Goutham Nithyananda


People also ask

How do I get a pipeline script in Jenkins?

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.


1 Answers

you can also use this, I needed this in ms so:

echo "TimeStamp: ${currentBuild.startTimeInMillis}"  echo "TimeStamp: ${Util.getTimeSpanString(System.currentTimeMillis())}" 
like image 139
dsaydon Avatar answered Oct 29 '22 21:10

dsaydon