Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1062995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:43:00+00:00 2026-05-16T18:43:00+00:00

We’re using TeamCity’s command line build runner to call a bat-file. The bat-file builds

  • 0

We’re using TeamCity’s command line build runner to call a bat-file. The bat-file builds our solution by calling the Visual Studio 2008’s “devenv.exe” and then it executes the unit tests and creates the correct folder structure.

What we would like to do is to stop executing the bat-file if the call to devenv fails and make the TeamCity to realize that the build failed. We can catch the failed devenv call by checking the ErrorLevel (which is 1 if the build failed) and we can exit our bat-file at that point. But how can we tell to the TeamCity that the build failed?

This is what we’ve tried:

call "build.bat"
IF ERRORLEVEL 1 EXIT /B 1

But TeamCity doesn’t recognize our exit code. Instead the build log looks like this:

[08:52:12]: ========== Build: 28 succeeded or up-to-date, 1 failed, 0 skipped ==========
[08:52:13]: C:\_work\BuildAgent\work\bcd14331c8d63b39\Build>IF ERRORLEVEL 1 EXIT /B 1 
[08:52:13]: Process exited with code 0
[08:52:13]: Publishing artifacts
[08:52:13]: [Publishing artifacts] Paths to publish: [build/install, teamcity-info.xml]
[08:52:13]: [Publishing artifacts] Artifacts path build/install not found
[08:52:13]: [Publishing artifacts] Publishing files
[08:52:13]: Build finished

So TeamCity will report that the build was successful. How can we fix this?

Solution:

TeamCity provides a mechanism called Service Messages which can be used to handle situations like this.
I’ve updated my build script to look like the following:

IF %ERRORLEVEL% == 0 GOTO OK
echo ##teamcity[buildStatus status='FAILURE' text='{build.status.text} in compilation']
EXIT /B 1
:OK

As a result TeamCity will report my build as failed because of a “Failure in compilation”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:43:01+00:00Added an answer on May 16, 2026 at 6:43 pm

    See Build Script Interaction with TeamCity topic.

    You can report messages for build log in the following way:

    ##teamcity[message text='<message text>' errorDetails='<error details>' status='<status value>']

    where:

    • The status attribute may take following values: NORMAL, WARNING,
      FAILURE, ERROR. The default value is NORMAL.
    • The errorDetails
      attribute is used only if status is ERROR, in other cases it is
      ignored.

    This message fails the build in case its status is ERROR and
    “Fail build if an error message is logged by build runner” checkbox is
    checked on build configuration general settings page. For example:

    ##teamcity[message text='Exception text' errorDetails='stack trace' status='ERROR']

    Update 2013-08-30:

    As of TeamCity 7.1 build failures should be reported using the buildProblem service message instead:

    ##teamcity[buildProblem description='<description>' identity='<identity>']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.