Biba
Biba

Reputation: 651

Inserting timestamp to folder name Jenkins

I want to rename file in Jenkins so that a file name would contain a timestamp. I installed zentimestamp plugin and tried to use it:

SET ts=${BUILD_TIMESTAMP}
ren file_name.zip file_name_%ts%.zip

but what i get is

file_name_${BUILD_TIMESTAMP}.zip

I got Date and Time Pattern in Global Properties set to: yyyyMMddHHmm. Can someone please explain me how to use BUILD_TIMESTAMP properly?

Upvotes: 2

Views: 2051

Answers (1)

Michael Powers
Michael Powers

Reputation: 2050

It looks like your code is from a Microsoft Batch file? If that's the case you'd reference BUILD_TIMESTAMP like this:

ren file_name.zip file_name_%BUILD_TIMESTAMP%.zip

BUILD_TIMESTAMP should be an environment variable if it's being injected correctly by the plugin. How you reference environment variables changes depending on what scripting solution is being used (e.g. batch, bash, ant, gradle, etc).

Upvotes: 2

Related Questions