JetBrains / TeamCity.ServiceMessages

.NET library to deal with TeamCity Service messages
http://confluence.jetbrains.net/display/TCDL/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ServiceMessages
Apache License 2.0
45 stars 13 forks source link

Unparseable date with TeamCity 6.5 #3

Closed daveneeley closed 12 years ago

daveneeley commented 12 years ago

This code

private void EmitTeamCityMessages()
{
    using (ITeamCityWriter writer = new TeamCityServiceMessages().CreateWriter())
    {
        writer.WriteBuildStatistics("CodeCoverageL", "0.330792774812305");
    }
}

Produces this error message in the output log

[06:52:48]: [Step 2/4] ##teamcity[buildStatisticValue key='CodeCoverageL' value='0.330792774812305' flowId='606841684' timestamp='2012-02-06T06:52:48.611-07:00'] [06:52:48]: [Step 2/4] Unparseable date: "2012-02-06T06:52:48.611-07:00"

I can see that the timestamp is being produced by this code in TimeStampUpdater.cs:

    public IServiceMessage UpdateServiceMessage(IServiceMessage message)
    {
      if (message.DefaultValue != null) return message;
      return new PatchedServiceMessage(message) { { "timestamp", myTimeService().ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz", CultureInfo.InvariantCulture) } };      
    }

However, I'm not sure how to override this format for TC 6.5.

jonnyzzz commented 12 years ago

Thank you for the issue. What locale was on your system? Do you have a patch for it?

daveneeley commented 12 years ago

The current culture is 1033 / en-US, on both the client and the teamcity server. I'm not sure how to patch it, because I don't see why it's invalid. ;)

daveneeley commented 12 years ago

If I drop the timezone offset (zzz) the issue goes away:

    public IServiceMessage UpdateServiceMessage(IServiceMessage message)
    {
      if (message.DefaultValue != null) return message;
      return new PatchedServiceMessage(message) { { "timestamp", myTimeService().ToString("yyyy-MM-dd'T'HH:mm:ss.fff", CultureInfo.InvariantCulture) } };      
    }
jonnyzzz commented 12 years ago

Thank you for info. It turned out, TeamCity expected timezone format without hour-minutes separator, i.e. -0700, but, .NET formatter used to return -07:00. I've added the fix