[JIRA] Created: (JENKINS-9693) maven.build.timestamp.format is not obeyed in maven builds

848 views
Skip to first unread message

djc@djc.id.au (JIRA)

unread,
May 15, 2011, 5:08:34 AM5/15/11
to jenkinsc...@googlegroups.com
maven.build.timestamp.format is not obeyed in maven builds
----------------------------------------------------------

Key: JENKINS-9693
URL: https://issues.jenkins-ci.org/browse/JENKINS-9693
Project: Jenkins
Issue Type: Bug
Components: maven2
Reporter: Dan C
Priority: Minor


Since Maven 2.1 it is possible to control the format of the {{maven.build.timestamp}} property [by setting the {{maven.build.timestamp.format}} property|http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Special_Variables]. This works correctly with mvn version 3.0.3:

{code:xml|title=pom.xml}
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>invalid.example.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
<build.timestamp>${maven.build.timestamp}</build.timestamp>
</properties>
<build>
<resources>
<resource>
<directory>src/main/filtered-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
{code}

{code:title=src/main/filtered-resources/test.properties}
Build-Timestamp: ${build.timestamp}
{code}

{code:title=target/classes/test.properties}
Build-Timestamp: 2011-05-15T18:56:20+1000
{code}

but in Jenkins 1.411 the default timestamp format is used instead:

{code:title=target/classes/test.properties}
Build-Timestamp: 20110515-1857
{code}

--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira


chrisr@containerstore.com (JIRA)

unread,
Sep 16, 2011, 3:03:39 PM9/16/11
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153017#comment-153017 ]

Chris Romack commented on JENKINS-9693:
---------------------------------------

So if maven.build.timestamp.format is ignored, is there another way to specify a custom timestamp format? I am running maven 3.0.3, Jenkins 1.428 and it is still not honoring maven.build.timestamp.format. Thanks.

jasonchaffee@gmail.com (JIRA)

unread,
Sep 19, 2011, 8:35:39 PM9/19/11
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153133#comment-153133 ]

Jason Chaffee edited comment on JENKINS-9693 at 9/20/11 12:35 AM:
------------------------------------------------------------------

I too, need to find a way to honor the timestamp format as the default breaks the build as I cannot have "-" in the format. Works fine in maven outside of jenkins though.

was (Author: jasonchaffee):
I too, need to find a way to honor the timestamp format as the default breaks by build as I cannot have "-" in the format.

jasonchaffee@gmail.com (JIRA)

unread,
Sep 19, 2011, 8:35:39 PM9/19/11
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153133#comment-153133 ]

Jason Chaffee commented on JENKINS-9693:
----------------------------------------

I too, need to find a way to honor the timestamp format as the default breaks by build as I cannot have "-" in the format.

> maven.build.timestamp.format is not obeyed in maven builds

clanceyp@gmail.com (JIRA)

unread,
Sep 28, 2011, 9:09:19 AM9/28/11
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153493#comment-153493 ]

patrick clancey commented on JENKINS-9693:
------------------------------------------

I have the same problem as Jason, broken builds when building with Jenkins. Has anyone found a work-a-round?

clanceyp@gmail.com (JIRA)

unread,
Sep 28, 2011, 5:09:19 PM9/28/11
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153493#comment-153493 ]

patrick clancey edited comment on JENKINS-9693 at 9/28/11 9:08 PM:
-------------------------------------------------------------------

I have the same problem as Jason, broken builds when building with Jenkins. Has anyone found a work-around?

There is a work-around using a Groovy snippet here...
http://stackoverflow.com/questions/802677/adding-the-current-date-with-maven2-filtering

Whilst not being particularly elegant, at least my builds are now working, which is always a plus! So a thanks to romaintaz for this.

was (Author: patrickc):


I have the same problem as Jason, broken builds when building with Jenkins. Has anyone found a work-a-round?

jasonchaffee@gmail.com (JIRA)

unread,
Sep 28, 2011, 8:44:19 PM9/28/11
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153535#comment-153535 ]

Jason Chaffee commented on JENKINS-9693:
----------------------------------------

The most disturbing part of this is that the build(s) work differently in Jenkins then they do simply running on the command-line. Not a very good thing if you are trying to have consistent and reproducible builds.

mathias.dam@gmail.com (JIRA)

unread,
Feb 17, 2012, 5:27:25 AM2/17/12
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=159208#comment-159208 ]

Mathias Dam commented on JENKINS-9693:
--------------------------------------

I have to agree with Jason Chaffee. While it is mostly just annoying, it begs the question: If this doesn't work as a command line build using Maven, what else might be different?

If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa

allenservedio@java.net (JIRA)

unread,
Mar 5, 2012, 8:51:26 AM3/5/12
to jenkinsc...@googlegroups.com

[ https://issues.jenkins-ci.org/browse/JENKINS-9693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=159852#comment-159852 ]

allenservedio commented on JENKINS-9693:
----------------------------------------

I wound up creating this timestamp via the Codehaus Build Number plugin (http://mojo.codehaus.org/buildnumber-maven-plugin/create-timestamp-mojo.html). Here is the Maven config that I used (in my plugin dependency management):

{code:xml}
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
</execution>
</executions>
<configuration>
<timestampFormat>yyyyMMddHHmmssSSS</timestampFormat>
<timestampPropertyName>releaseTimestamp</timestampPropertyName>
</configuration>
</plugin>
{code}

Am I correct that the reason this was not fixed already is that the point in the maven lifecycle where the statically formatted timestamp is created, the pom file(s) have not been evaluated. As such, it does not have access to this property (maven.build.timestamp.format) and so does not know that the user has defined it? If that is true, is there something else that can be used in Jenkin's Maven integration that can get access to this property and use it correctly?

Thanks!
Allen

If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa

jenkins@adamrofer.com (JIRA)

unread,
Sep 13, 2012, 9:16:49 PM9/13/12
to jenkinsc...@googlegroups.com
Adam Rofer commented on Bug JENKINS-9693

All of the above workarounds provide different timestamps in each submodule in a multi-module build. The only thing I managed to get working was the following code:

<plugin>
    <groupId>com.github.goldin</groupId>
    <artifactId>timestamp-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>set-specific-timestamp</id>
            <goals>
                <goal>timestamp</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
                <time>{{ 
                         def newdate = null;
                         try {
                             newdate = Date.parse( "${maven.build.timestamp.format}", "${maven.build.timestamp}");
                         } catch (Exception e) {
                             newdate = Date.parse( "yyyyMMdd-HHmm", "${maven.build.timestamp}");
                             println "THANKS JENKINS, FOR JENKINS-9693";
                         }
                         newdate 
                 }}</time>
                <timestamp>
                    <property>actual-timestamp</property>
                    <pattern>${maven.build.timestamp.format}</pattern>
                </timestamp>
            </configuration>
        </execution>
    </executions>
</plugin>

...and then use actual-timestamp as your timestamp property.
This assumes you already have maven.build.timestamp.format set as a property.

Note that you can put whatever pattern you want in the <pattern> field, in this case it just formats it the way you originally wanted it

Also note that this will only reach minute resolution on Jenkins builds since that's what Jenkins munges it to.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

jenkins@adamrofer.com (JIRA)

unread,
Sep 13, 2012, 9:18:49 PM9/13/12
to jenkinsc...@googlegroups.com
 
Adam Rofer edited a comment on Bug JENKINS-9693

All of the above workarounds provide different timestamps in each module in a multi-module build. The only thing I managed to get working was the following code:

This message is automatically generated by JIRA.

If you think it was sent incorrectly, please contact your JIRA administrators.

jenkins@adamrofer.com (JIRA)

unread,
Sep 13, 2012, 9:20:49 PM9/13/12
to jenkinsc...@googlegroups.com
 
Adam Rofer edited a comment on Bug JENKINS-9693

All of the above workarounds provide different timestamps in each module in a multi-module build. The only thing I managed to get working was the following code:

<plugin>
    <groupId>com.github.goldin</groupId>
    <artifactId>timestamp-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>set-specific-timestamp</id>
            <goals>
                <goal>timestamp</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
                <time>{{ 
                         def newdate = null;
                         try {
                             newdate = Date.parse( "${maven.build.timestamp.format}", "${maven.build.timestamp}");
                         } catch (java.text.ParseException e) {
                             newdate = Date.parse( "yyyyMMdd-HHmm", "${maven.build.timestamp}");
                             println "THANKS JENKINS, FOR JENKINS-9693";
                         }
                         newdate 
                 }}</time>
                <timestamp>
                    <property>actual-timestamp</property>
                    <pattern>${maven.build.timestamp.format}</pattern>
                </timestamp>
            </configuration>
        </execution>
    </executions>
</plugin>

...and then use actual-timestamp as your timestamp property.
This assumes you already have maven.build.timestamp.format set as a property.

Note that you can put whatever pattern you want in the <pattern> field, in this case it just formats it the way you originally wanted it

Also note that this will only reach minute resolution on Jenkins builds since that's what Jenkins munges it to.

This message is automatically generated by JIRA.

If you think it was sent incorrectly, please contact your JIRA administrators.

tsavolai@gmail.com (JIRA)

unread,
Oct 18, 2012, 6:14:42 AM10/18/12
to jenkinsc...@googlegroups.com

Reproduced on Jenkins ver. 1.486

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

marcomsousa@gmail.com (JIRA)

unread,
Nov 9, 2012, 6:59:42 AM11/9/12
to jenkinsc...@googlegroups.com
Marco Sousa commented on Bug JENKINS-9693

I migrate from Hudson to Jenkins and now I have this bug. In hudson work's fine.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

jens.hohmuth@xcom.de (JIRA)

unread,
Apr 25, 2013, 10:01:32 AM4/25/13
to jenkinsc...@googlegroups.com
Jens Hohmuth commented on Bug JENKINS-9693

Still broken for me in Jenkins version 1.511

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

rbierman@home.nl (JIRA)

unread,
Jul 8, 2013, 9:36:58 AM7/8/13
to jenkinsc...@googlegroups.com
Ron Bierman commented on Bug JENKINS-9693

Fixed this issue in the maven-interceptors project. (https://github.com/jenkinsci/maven-interceptors/pull/2).

We need to release a new version of that project and update the maven-plugin project so it uses that new version.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

scm_issue_link@java.net (JIRA)

unread,
Mar 1, 2014, 4:14:00 AM3/1/14
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Ron Bierman
Path:
maven-agent/src/main/java/hudson/maven/agent/Main.java
maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java
maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java
pom.xml
http://jenkins-ci.org/commit/maven-interceptors/021aba7769f46965103686b4ab01de5dcadc0530
Log:
Fixed issue: JENKINS-9693
Removed the call to request.getProjectBuildingRequest() because this call creates a new ProjectBuildingRequest object and set's the BuildStartTime null.
Maven takes care of this by it self later.

Modified repository location in the pom.xml.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

scm_issue_link@java.net (JIRA)

unread,
Mar 1, 2014, 4:14:01 AM3/1/14
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Christoph Kutzinski
Path:
maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java
http://jenkins-ci.org/commit/maven-interceptors/8b8c85a5fad5900a09b78e6cc5603e9d580fd89a
Log:
Merge pull request #2 from rbierman/JENKINS-9693

[Fixed JENKINS-9693] maven.build.timestamp.format is not obeyed in maven builds

Compare: https://github.com/jenkinsci/maven-interceptors/compare/142041fa53ce...8b8c85a5fad5

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

scm_issue_link@java.net (JIRA)

unread,
Mar 1, 2014, 4:14:01 AM3/1/14
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Ron Bierman
Path:
.gitignore
maven-agent/pom.xml
maven-agent/src/main/java/hudson/maven/agent/Main.java
maven-interceptor/pom.xml
maven3-agent/.gitignore
maven3-agent/pom.xml
maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java
maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/RealFilterOutputStream.java
maven3-agent/src/main/resources/org/jvnet/hudson/maven3/agent/classworlds.conf
maven3-interceptor-commons/pom.xml
maven3-interceptor-commons/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java
maven3-interceptor-commons/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java
maven3-interceptor-commons/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java
maven3-interceptor-commons/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java
maven3-interceptor-commons/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java
maven3-interceptor/.gitignore
maven3-interceptor/pom.xml
maven3-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java
maven3-interceptor/src/main/java/org/apache/maven/cli/MavenExecutionRequestBuilder.java
maven3-interceptor/src/main/java/org/apache/maven/cli/MavenExecutionRequestsBuilderException.java
maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven3Launcher.java
maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/HudsonMavenExecutionResult.java
maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectBuildResult.java
maven3-interceptor/src/main/java/org/jvnet/hudson/maven3/listeners/MavenProjectInfo.java
maven31-agent/pom.xml
maven31-agent/src/main/java/jenkins/maven3/agent/Maven31Agent.java
maven31-agent/src/main/java/jenkins/maven3/agent/Maven31Main.java
maven31-agent/src/main/java/jenkins/maven3/agent/RealFilterOutputStream.java
maven31-agent/src/main/resources/jenkins/maven3/agent/classworlds.conf
maven31-interceptor/pom.xml
maven31-interceptor/src/main/java/org/apache/maven/cli/DefaultMavenExecutionRequestBuilder.java
maven31-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven31Interceptor.java
maven31-interceptor/src/main/java/org/jvnet/hudson/maven3/launcher/Maven31Launcher.java
pom.xml
http://jenkins-ci.org/commit/maven-interceptors/7005329394fb515a70b6aa4a37e45167fefda86a
Log:
Merge branch 'master' into JENKINS-9693

Conflicts:
maven-agent/src/main/java/hudson/maven/agent/Main.java
maven3-agent/src/main/java/org/jvnet/hudson/maven3/agent/Maven3Main.java

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

scm_issue_link@java.net (JIRA)

unread,
Mar 1, 2014, 5:54:59 AM3/1/14
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Christoph Kutzinski
Path:
pom.xml
http://jenkins-ci.org/commit/maven-plugin/dae6ef31fc5152d65f5543f61f1c911fcb0dbd38
Log:
[Fixed JENKINS-9693] maven.build.timestamp.format is not obeyed in maven
builds (integrate maven-interceptors 1.5)

Compare: https://github.com/jenkinsci/maven-plugin/compare/d73f82ed2a23...dae6ef31fc51

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

jglick@cloudbees.com (JIRA)

unread,
Aug 29, 2014, 6:27:04 PM8/29/14
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-9693

There is a commit by @kutzi claiming to fix this; should this still be open?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

anthonyagresta@gmail.com (JIRA)

unread,
Dec 1, 2014, 10:49:10 AM12/1/14
to jenkinsc...@googlegroups.com

After updating to the latest version of Jenkins, this issue appears to be fixed.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.

daniel@beckweb.net (JIRA)

unread,
Dec 14, 2014, 9:04:08 AM12/14/14
to jenkinsc...@googlegroups.com
Daniel Beck resolved Bug JENKINS-9693 as Fixed

Comment indicates this has been resolved.

Change By: Daniel Beck (14/Dec/14 2:02 PM)
Status: Open Resolved
Resolution: Fixed
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
Reply all
Reply to author
Forward
0 new messages