Stop gradle build gracefully, i.e. without an exception, from within the build script - gradle

Is it possible to stop a gradle build gracefully, meaning without throwing an exception? It is not
System.exit() as this kills the daemon
throw SomeException
Background: for occasional debugging I want to run some method after the build is set up and show some information, but then stop and don't actually run the build. Throwing an exception for some debugging situation is probably good enough, but without the exception it would be even nicer.

Related

Why does Teamcity send a keyboard interrupt to kill my build?

I have a build running in TeamCity, with only one build step: launching a BAT file. TeamCity sometimes kills my build with a (double) keyboard interrupt, and I have no idea why. The output at the end of the build is like this:
Running build failed.
Error:
NUnit test failed (7).
Starting BuildFailureTarget: recover
Uninstalling service under test..Terminate batch job (Y/N)?
^C
Process exited with code -1073741510
This build runs some integration tests via NUnit, after installing a Windows service, with a SQL database. If any of the tests fail, the build script (which uses FAKE, F#'s Make) runs some cleanup—uninstalls the service, tears down the database. It's the same cleanup code that runs when the build passes, only the target name is different (recover). It seems that TeamCity only kills the build when some tests have failed. I should note that the message "Uninstalling service under test" is from a subprocess which is running the uninstaller. This still happens even if we turn off several failure conditions such that the build (spuriously) passes after several tests fail (we are not using Java, so we assume that one is irrelevant):
I can't figure out why TeamCity is killing my build before it is done. How do I figure out what would cause TeamCity to issue this interrupt?
It seems that TeamCity does this if it detects dangling processes (not sure how to be more precise about that). What we had happening was that an exception was being thrown by a third-party library while we were running a subprocess, before the code that stopped that process. The exception was handled, and the cleanup that got triggered by the exception would have resulted in the process getting shut down anyway (through another means), but before that cleanup was finished, TeamCity was killing our build: which ironically meant that the process never did get shut down.
Our solution was to catch the exception and ensure the first shutdown code got called before failing. Ultimately we were not able from a TeamCity side to get more clarity on what was happening: we found the bug by careful analysis of our code. However it seems that this happens when standard cleanup logic for subprocesses fails.

Is there a way to pause a maven multi-module build and resume later?

So this humungous package is trying to get installed on my VM for the past 5 hours. Its still going strong and looks like it has downloaded the entire Internet already. I need to shut my laptop down. Is there a command line tool to tell Maven to take a break, chill for some time, and resume from where it left later?
Edit: I see a very subtle difference between this and the existing question that has been pointed out. I have been using the -rf flag to recover from a failed build for some time now. But I am not aware of the intricacies of the workings of Maven so I wasn't sure if it would be able to recover if I killed the mvn process from the command line (or if my laptop ran out of battery and was forced to shut down), even if the build process was going on smooth. Here's an analogy - I like to think of Maven as someone managing a complex set of tasks. If some task fails, the manager keeps note of that, halts all the operations and reports to the seniors and waits till his issue is fixed. I believe that as soon as maven finds out something has broken, it saves the state of the build process to be able to resume later. But what happens if someone comes and kills the manager. Or in the case of what I did, if I kill -9 the maven process. Would maven be able to save a copy of the build state? I wasn't so sure. That's what I wanted to check
You can use -rf command line switch to restart the build from given package.
For example if your project consists of parent, child1, child2 builds, you can stop the build e.g. at child2 and restart it using (assuming you were doing clean install):
mvn clean install -rf :child2

Failed to start build #XXX on agent, disable the agent?

I have a set of Java GUI tests on Windows that sometimes fail to cleanup a file or a window due to a lock. The next time any test starts I get a "Failed to start build #XXX on agent" message. The build then fails very quickly on that agent, which frees the agent to run another build and this results in a lot of builds failing with the same message on the same agent.
Is there a way to disable the agent when the problem occurs and maybe send a notification?
Rather than disabling the agent, you could try cleaning the files which get locked. Try using Swabra (Build Files Cleaner)

How do I ignore pending rspec tests in Rubymine?

I have many pending tests in my application, and they make it hard to view a failed test in Rubymine.
Is there a way, either through rspec command line options or Rubymine settings, to disable running pending tests entirely? Or at least not show them in the view? I know of the button to not show passing tests, but that doesn't help with pending tests.
Rspec 3.1? Pending's meaning has changed... try skipped instead?
From: https://www.relishapp.com/rspec/rspec-core/v/3-1/docs/pending-and-skipped-examples
An example can either be marked as skipped, in which is it not
executed, or pending in which it is executed but failure will not
cause a failure of the entire suite. When a pending example passes
(i.e. the underlying reasons for it being marked pending is no longer
present) it will be marked as failed in order to communicate to you
that it should no longer be marked as pending.

Team City how to have non blocking build step when running exe

We've recently found that an acceptance test project fails occasionally on our build server- due to our web drivers Type is not resolved error. I'm trying an experiment to see if its a question of timing of build steps. To this end I've tried to create a separate build step which launches the webdriver executable separately and then proceed onto the unit tests - the issue I have is when I launch the process it blocks the next step after it has successfully started.
eg. Type is not resolved for member 'OpenQA.Selenium.WebDriverException,WebDriver, Version=2.41.0.0, Culture=neutral, PublicKeyToken=null'..
Is there a way I can progress to the next build step after I call an exe?
Thanks
Do you have multiple build agents? Have you considered splitting this into separate build configurations and having triggers on previous build configurations?
You could have configurations:
Compile,
Webdriver, triggered on successful compile completion
Unit Tests, triggered on successful compile completion.
It's not nice, but it should give you the non-blocking behavior you're after. I can't see any other way of making it happen, build configurations are supposed to run as a linear sequence.

Resources