Pass gradle step when detekt sucessfully autocorrects - gradle

I run detekt with gradle with autocorrect enabled. I fail the build on detekt errors. This results in me running detekt twice for autocorrectable problems:
The build fails and is autocorrected.
The build passes.
Is it possible to configure detekt to do both in one step? I.e. detekt errors, autocorrect them, and therefore assert that everything is fine by not failing (build step succeeds)?

Related

how to get maven to run all tests but still fail build on compile error

Suppose I have a multi-module maven project. I want to run it in such a way that:
If a test fails, I still want to compile and test the next module. This sounds like a job for --fail-never, but see below.
If there are test failures, I don't really care if the build succeeds or fails. Ideally this would be configurable, but whatever.
If there are compiler errors, then the build should fail. I think this rules out "fail-never"?
You can use surefire parameter: maven.test.failure.ignore
mvn test -Dmaven.test.failure.ignore
With this options failing test will not fail build a module and finally whole build will have success result.

Using Protractor, failing test cases using maven and then maven build should fail or not?

Some of test cases are failed so due to that maven build is also failed .Just because of maven failure , Jenkins build is also failed.
So is it right or something is wrong in it?
In your Jenkins job you could run Maven with either of the following parameters:
-DskipTests=true to skip test execution entirely
-Dmaven.test.failure.ignore=true to ignore test failures
But if the tests are important (and they certainly should be :) then perhaps ignoring them (or not running them) is the wrong approach, perhaps you should instead fix the failed tests.

Fail the Jenkins build if there is test failures in a multi-module Maven Project

At the moment I have a project, lets call it mightymouse. Mightymouse POM is a multi-module project for mightymouse-web and mightmouse-backend.
Both of the sub modules have tests. In my situation, the mightymouse-web project compiles, test, package, install, deploys first. Then then -backend project goes through, only to fail during the integration-test stage. (Yet, it still goes through to the deploy stage).
The Jenkins job is setup to execute mvn clean deploy.
Question: Is there anyway to prevent Maven from going all the way to the deploy step on any module failing it's tests?
By default, a maven multi module build also uses the fail-fast option
--fail-fast - the default behavior - whenever a module build fails, stop the overall build immediately
Moreover, by default the maven-failsafe-plugin already fails as soon as an integration test fails via the testFailureIgnore option
Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion.
User Property: maven.test.failure.ignore
Default: false
Note that the maven-surefire-plugin has the same for unit testings.
Hence, by default a multi-module build should stop as soon as a test fails (unit test or integration test), no further module would be built and not further maven phase should be invoked.
However, a Maven Jenkins job (and not a freestyle Jenkins job invoking Maven) set this option to true by default and hence the build would not fail, it will keep on and deploy, while the job would be set to UNSTABLE and not SUCCESSFUL (but still deploying).
As such, you could change your maven invocation in your Jenkins job to:
mvn clean deploy -Dmaven.test.failure.ignore=false
Overriding thus Jenkins default settings and meeting your requirements.

Fail Jenkins job only if there is an error/issue with the job

I have a Jenkins job which runs certain SoapUI test cases using the maven plugin.The Jenkins build fails even if one of the test cases fail.I do not want this to be the case and want the job to fail only when there is an issue with the job(like it terminates in between due to some exception) or if the server is down.How can I do that?
Have you tried to skip test cases in your Maven run? Use the code below in maven properties section of maven plugin:
maven.test.failure.ignore=true

When does SonarQube plugin run unit test?

I'm using SonarQube4.2 with jekins plugin. I configured Sonar as Post-Build Action on Jenkins, and It's work fine. I'm wondering that if maven compiles test sources before executing the sonar action, sonar automatically run these test units, but maven only compiles main sources, then sonar doesn't run unit tests. If Jenkins execute mvn test phase before Sonar as Post=Build Action, Jenkins duplicate running unit tests. I want to compile sources, running unit tests and executing Sonar, hence I configured mvn test-compile with Post-Build Action for Sonar in Job. Is it usual way? Does any body knows better way to executiong sonar with Jenkins.
Regards

Resources