Team City Build Fails when "the build process exit code is not zero" Is Unchecked - jasmine

I have several build steps that need to run regardless of (test failure, in this case).
However when tests in one step fail, the whole build fails and quits. To overcome this problem I unchecked the "build process exit code is not zero".
After this the build fails more quickly at step 2, which is install of grunt-cli
Is there a (better) way to have my build continue, even on a non-zero exit from a previous step? I tried muting, but this is not what I was hoping for.
TeamCity Enterprise 9.1.7 (build 37573)

If this is a commandline build step, you can add "exit 0" to force the exit code to always be 0. Since you are reporting tests, you will still see the failed tests in TeamCity.

When you configure the build stteps, you can set an execution condition of Execution policy to: Even if some of previous steps failed
You can also set to: Always, even if build stop command was issued if you want to do some cleanup on your agent after the execution of your tests.

Related

After Bamboo CI runs it's indicating build job is success even though some of the Cypress tests are failing

Running Cypress tests in Bamboo.Bamboo build job is showing success with green mark even though Cypress tests has some failure tests.
I expect, if cypress test has some failure then Bamboo build status indicating that build is failed with red cross symbol
Bamboo always expects the exit code exit 0 for the build to pass successfully. Any other exit code value will fail the build.
You may add the below snip at the end of your plan in a script task based on where your build is running and then the Build log should list the exit code result.
For Windows based agents:
echo ==========
$LastExitCode
echo ==========
For Linux based agents:
echo ==========
echo $?
echo ==========
This should give you an idea on what is being sent back to Bamboo to decide. You may then alter your plan accordingly to produce the right error code.

TeamCity pass codebase changes to next build

I have a TeamCity build that sometimes fails too early.
What I mean by that is that the first few steps are for "provisioning" (setting up the testing environment) and the testing of my code itself comes later.
Sometimes (for whatever reason) the build fails during one of the "provisioning" steps. This is not a problem since running the build again usually works fine.
But - the "changes" are not passed along to the next run of the build.
I am using this command as part of my build to output the "changes" that came from my codebase:
copy "%system.teamcity.build.changedFiles.file%" changelog.txt
So I need a way to tell TeamCity "hey, ignore the last run, that failure doesn't count because it didn't test my code, I want the next run to contain the same 'changes' in system.teamcity.build.changedFiles.file"
How can I do that?
Have you tried build chains with dependencies? They can be set up to only execute if the build (including tests) is successful: http://blog.jetbrains.com/teamcity/2012/04/teamcity-build-dependencies-2/

How to make Jenkins run failed tests first, and upon successful completion, run all the tests again?

Let's pretend that we have a jenkins job called functional-tests. I am looking for a way to configure this job, so that when it fails due to one or more of the tests failing, on the next run (e.g. triggered by a commit) it only runs the failed tests.
Now if this run was successful, it automatically triggers another build of the job to run all the tests.
However if the run was unsuccessful, it will continue to only run the tests that were failed in the previous run.
I think the only thing I need, is to pass the state of the previous build as well as the tests that were failed to the current job.
We are using Maven and Surefire for the build.

How to integrate MSTest in your TeamCity build process

How do I run MSTest as part of my build process in TeamCity? What are the pitfalls?
This answer is specifically for TeamCity 7.1 on Windows, but may apply to other environments.
In your TeamCity build configuration, on the General Settings page
Artifact paths: Artifacts\MSTest => MSTest
Create a new Command Linebuild step
Custom script: if not exist Artifacts\MSTest mkdir Artifacts\MSTest
Create a new MSTestbuild step
List assembly files: **\bin\**\*.Tests.dll
Results file: Artifacts\MSTest\testResults.trx
Pitfalls
Using wildcards when specifying which test assemblies to run
You can use wildcards when specifying which test assemblies to run in the MSTest build step, although it is unclear exactly how they work. A bug report has been filed.
The build process doesn't stop when tests fail
Be aware that if some of your tests fail and the build is marked as failed, the MSTest build step itself does not fail. This causes problems if you have build steps after the MSTest build step which you don't want to run if you have test failures (e.g. it may not make sense to produce an installer or documentation of a build you know has bugs). The problem will hopefully be fixed in later versions of TeamCity.
If you want your build process to stop when you have test failures, you can create a new build step that uses the TeamCity REST API to detect if the current build has been marked as failed (remember that when tests fail, the build step is not marked as failed, but the build is), and then fail the current build step explicitly. Example:
Create a new Powershell build step
Script: Source code
Source code: See script below
Make sure your newly created build step comes immediately after your MSTest build step
Make sure every build step after this one has Execute step set to Only if all previous steps were successful
Script:
$xml = [xml](curl --request GET http://USERNAME:PASSWORD#HOSTNAME/httpAuth/app/rest/builds/%teamcity.build.id%)
Microsoft.PowerShell.Utility\Select-Xml $xml -XPath "/build" | % { $status = $_.Node.status }
if ($status -eq "FAILURE") {
throw "Failing build step on purpose"
}

Failed build trigger in team city TeamCity

Is it possible to Trigger an exe to run on a failed build? Can you do this within Team City?
If you specifically want the failed builds, you can set up the dependent build as Eric said, and have that secondary buildscript use the REST API to pull up a list of the failed builds for the actual project.
If the latest build is in that failed builds list, then tell the build script to run the executable. If not, then you're all done!
http://confluence.jetbrains.net/display/TW/REST+API+Plugin
I don't think it's possible to trigger an executable to run only on failed TeamCity builds. TeamCity usually allows you to do things either always or only upon successful builds.
It would be possible to trigger an executable to run after this build is finished (failed or successful).
If that would work for you, you could set up a new build configuration that runs the executable. The new build configuration would have a "finish build" trigger. This would cause the executable to be run whenever the other build is completed.
You should add another build step with the exe you want to run and set the correct option to execute.execution options

Resources