Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Errors should be logged in the build log #24

Open
bacar opened this issue Oct 6, 2014 · 12 comments
Open

Errors should be logged in the build log #24

bacar opened this issue Oct 6, 2014 · 12 comments

Comments

@bacar
Copy link

bacar commented Oct 6, 2014

If there's an error (eg authentication failure with stash due to bad password), there seem to be no clues in the build log that this happened.

It would be useful to log errors, and optionally fail the build if there are any errors publishing to stash.

@bacar
Copy link
Author

bacar commented Feb 16, 2015

https://devnet.jetbrains.com/message/5243967#5243967

Apparently you can log to the build log using build.getBuildLogger().message(msg)

Also https://devnet.jetbrains.com/message/5299159#5299159 for other logging.

@mendhak
Copy link
Owner

mendhak commented Feb 17, 2015

Thanks for the link, it was very simple in retrospect but finding this kind of information hasn't been easy with Jetbrains.

I've logged to teamcity-server.log Messages should look like this:

[2015-02-17 20:38:09,178]   INFO -   jetbrains.buildServer.SERVER - TEAMCITY-STASH:Sending build status to http://127.0.0.1:7990/rest/build-status/1.0/commits/f0dfdd0c8b1dffc75$
[2015-02-17 20:38:09,178]   INFO -   jetbrains.buildServer.SERVER - TEAMCITY-STASH:With body: {
    "state": "SUCCESSFUL",
    "key": "8",
    "name": "Build #3, Success",
    "url": "http://localhost:8111/viewLog.html?buildId=8&buildTypeId=Blerk_Groooo",
    "description": "[blerk :: groooo] February 17, 2015 20:38"
}
[2015-02-17 20:38:09,178]   INFO -   jetbrains.buildServer.SERVER - TEAMCITY-STASH:Auth header: Z3JhYWFhYWFhOmFzZGxrZmphc2RrbGZq
[2015-02-17 20:38:09,179]  ERROR -   jetbrains.buildServer.SERVER - TEAMCITY-STASH:Could not send data to Stash.
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)

@bacar
Copy link
Author

bacar commented Feb 17, 2015

Awesome. That is going to be super helpful.

Agreed re finding info, I asked their support directly and they helped out.

Can we also get basic info into the build log?

  • any attempt (successful or otherwise) to update status, at beginning/end of run, & status (success/failure)
  • any failure messages (eg failed auth), any exceptions
  • always log the stash instance and username used

@bacar
Copy link
Author

bacar commented Feb 18, 2015

To be clear, I mean:

  • detailed info into server log (as you have) for plugin debugging
  • summary into build log (for easy troubleshooting by non admin users who don't have access to the server log)

@mendhak
Copy link
Owner

mendhak commented Feb 18, 2015

Aha I understand. This cannot log to the build log since it is a build feature and it operates asynchronously. I wouldn't want to make it synchronous (I don't think it's possible but again could be wrong) because it then has the potential of breaking or delaying the build

@bacar
Copy link
Author

bacar commented Feb 18, 2015

I guess you're talking about the way your plugin posts status update work to an ExecutorService in ChangeStatusUpdater.java - I don't know enough about the build feature plugin architecture to know, but are you sure it won't just work anyway, to write to the build log from inside this task?

@bacar
Copy link
Author

bacar commented Mar 29, 2015

Did you happen to get the chance to try this out?

@mendhak
Copy link
Owner

mendhak commented Mar 29, 2015

Looks like I had a draft and forgot to press send. Yes, it was one of the aims at the beginning. However, the architecture doesn't allow it as it can potentially fail the build for unrelated reasons.

I think what you may be looking for instead is just an extra build step. Possibly a build step which takes the results of a previous build step and uses some scripting or a curl command to call Stash and update it. That's the only way I can think of that would allow output in the web build log.

Edit: If there's a way to get a build feature to write to the web build log, I haven't seen it anywhere. I only remember trying to do it then learning the reason why I couldn't do it. Similarly, the github updater also doesn't do it

@bacar
Copy link
Author

bacar commented Mar 29, 2015

Are you saying that using build.getBuildLogger().message(msg) can make it fail, or that making it synchronous can make it fail? I'm not suggesting making it synchronous. Have you tried contacting their support? They're quite responsive - we have a paid contract but as a plugin developer they might still help you out.

@mendhak
Copy link
Owner

mendhak commented Mar 29, 2015

Can do - I'll email them and see what they say. It'll be a while before I revisit this though (busy with work stuff), so in the meantime if you want to play around with the code to see if it works, do let me know. I'll reopen this till I know for sure

@mendhak mendhak reopened this Mar 29, 2015
@oak-wildwood
Copy link

Any movement on this? We've been using this for months and all of the sudden it fails to report a build status. Restarting TC fixed it once or twice, but doesn't seem to help this time. I don't see anything in the teamcity-server.log and after seeing this thread I don't expect to. Any reason we can't just add a call to write to a new log file?

@mendhak
Copy link
Owner

mendhak commented Jan 25, 2016

I think it should be possible, the Loggers is using a default built in log. I haven't tried creating a custom log file, I could try if I find some time but at the moment I don't have much. If you've got time would be helpful to see how this is done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants