dice2011
dice2011

Reputation: 1037

Unix time stamp in Jenkins

I use Invoke top-level Maven targets to make a deploy to the artifactory.

I need to use a UNIX timestamp as a maven deployment property in the pom.xml.

Is there a variable in Jenkins, that keeps timestamp in UNIX format? I've tried BUILD_TIMESTAMP, but the format is wrong. Or maybe there are any better ways to do it?

Thanks in advance.

Please, don't advice me Promote artifactory plugin. There are some reasons, that now allow me to use it.

Upvotes: 0

Views: 1018

Answers (1)

fishi0x01
fishi0x01

Reputation: 3759

If your Jenkins runs on a UNIX system you could run a shell command and store the output in a variable:

def unixTs = sh(
           script: 'date -uIseconds',
           returnStdout: true
         ).trim()

Upvotes: 1

Related Questions