I’m using jenkins to build package. My package uses jankins environment variable BUILD_ID, which provides build date: https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables
Problem is, that i need to use that date in xml configuration file, in element of type dateTime from schema http://www.w3.org/2001/XMLSchema.
Jenkins uses format
YYYY-MM-DD_hh-mm-ss
for BUILD_ID var, and dateTime field needs format
YYYY-MM-DDTHH:MM:SS
(‘T’ instead of ‘_’ between date and time, and ‘:’ instead of ‘-‘ as time separator).
I know there is plugin for jenkins that allows to set custom date format for BUILD_ID variable, but i cant touch jenkins. Is it possible to write an “local” script / hook (by local i mean in the scope of my project, without any changes to external tools) that will convert that BUILD_ID after it read it from jenkins ? Right now i read BUILD_ID with that line in pom’s element:
<buildinfo.timestamp>${env.BUILD_ID}</buildinfo.timestamp>
There is a tiny maven plugin called maven-timestamp-plugin that might help you. It creates a timestamp in the format you like and writes it into a system property which you can access similar to the Jenkins
BUILD_ID.Your plugin configuration would look something like this:
… and in your XML file you can write
<buildinfo.timestamp>${timestamp}</buildinfo.timestamp>