Jenkins build not failing when maven deploy task fails - maven

I have a Jenkins (Maven) job that builds and deploys a web service to a Tomcat 8 server.
If the deployment to the Tomcat fails the Jenkins job still finishes with success.
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Deployed application at context path /dims but context failed to start
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.625s
[INFO] Finished at: Tue Oct 25 12:14:21 CEST 2016
[INFO] Final Memory: 17M/40M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS
Is there a way to make the Jenkins job fail if the deployment fails?

if you use jenkins i advise you to use jenkins deploy plugin
https://wiki.jenkins-ci.org/display/JENKINS/Deploy+Plugin

I think this is a bug in the tomcat maven plugin.
I had the same problem and use Jenkins plugin called Jenkins Text Finder. I added a post-build action called "Jenkins Text Finder" to the end of my Jenkins job. I leave the "Files" input box empty, but check the "Also search the console output" checkbox. In the regular expression inputbox I put "but context failed to start". The other two checkboxes remain unchecked.
This leads to the following output
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Deployed application at context path / but context failed to start
[INFO] ----------------
[INFO] BUILD SUCCESS
[INFO] ----------------
[INFO] Total time: 01:23 min
[INFO] Finished at: 2016-12-29T21:15:41+01:00
[INFO] Final Memory: 117M/472M
[JENKINS] Archiving /var/lib/jenkins/workspace/jenkins-test/core/pom.xml to cz.semanta/xf3/r8_2/xf3-r8_2.pom
[INFO] ---------------------
channel stopped
Checking console output
/var/lib/jenkins/jobs/jenkins-test/builds/6/log:
[INFO] FAIL - Deployed application at context path / but context failed to start
Build step 'Jenkins Text Finder' changed build result to FAILURE
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE
which is good enough for me.

Related

Sonarqube analysis total time/duration [SonnarScanner for Maven]

I'm using Sonarqube 8.9 LTS with SonarScanner for Maven.
When we run any scan with SonarScanner for Maven, the normal output is:
[INFO] CPD Executor CPD calculation finished (done) | time=3287ms
[INFO] Analysis report generated in 2397ms, dir size=64 MB
[INFO] Analysis report compressed in 25206ms, zip size=24 MB
[INFO] Analysis report uploaded in 1866ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://127.0.0.1:9000/dashboard?id=project_id
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://127.0.0.1:9000/api/ce/task?id=task_id
[INFO] Analysis total time: 18:30.103 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19:37 min
[INFO] Finished at: 2021-10-22T02:23:22Z
[INFO] ------------------------------------------------------------------------
Where do i find this information after the scan is completed?
I can't find it in the web ui or the rest api.
This information is not stored on the server.
I did ask the same question on sonar community and got the following response:
You won’t find this stored on the server; it’s not sent to the server
and is only available where you see it: in the client-side analysis
logs.
If you are
Global Administrators can view the status of Background task at Administration > Projects > Background Tasks.
Project administrators can see the tasks for a project at Project Settings > Background Tasks
More details in here Background Tasks

How to use gradle-enterprise-maven-extension behind a proxy?

Willing to use the gradle-enterprise-maven-extension
to migrate a project from maven to gradle,
I cloned the maven-build-scan-quickstart provided by the gradle team.
But runing mvn install, as specified, after acceptation of gradle terms of service,
I receive the following message:
UnknownHostException: scans-in.gradle.com
I tried to configure the proxy in several manners:
Using commannd line option:
mvn install -Dhttps.proxyHost=localhost:8888 -Dhttps.proxyPort=localhost:8888
Using a gradle.properties file in a directory at %GRADLE_USER_HOME% directory location:
(proxy is also configured in maven's settings.xml and need no password it works fine when using maven in standard ways)
gradle.properties :
systemProp.http.proxyHost=localhost
systemProp.http.proxyPort=8888
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost|127.0.0.1
systemProp.https.proxyHost=localhost
systemProp.https.proxyPort=8888
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost|127.0.0.1
But I still receive the same message:
~/github/maven-build-scan-quickstart
$ mvn install
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.830 s
[INFO] Finished at: 2019-12-31T13:09:19+01:00
[INFO] ------------------------------------------------------------------------
[INFO] 7 goals, 7 executed
Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service. Do you accept these terms? (yes/no): yes
[INFO] Gradle Terms of Service accepted.
[INFO]
[INFO] Publishing build scan...
[INFO]
[INFO] A network error occurred.
[INFO]
[INFO] The hostname 'scans-in.gradle.com' could not be resolved.
[INFO] You may be disconnected from the Internet.
[INFO]
[INFO] If you require assistance with this problem, please report it via https://gradle.com/help/plugin and include the following information via copy/paste.
[INFO]
[INFO] ----------
[INFO] Maven version: 3.6.2
[INFO] Extension version: 1.3.3
[INFO] Request URL: https://scans-in.gradle.com/in/maven/3.6.2/1.3.3
[INFO] Request ID: 1234567e-abcd-23de-c2d3-3fbbccd14a32
[INFO] Exception: java.net.UnknownHostException: scans-in.gradle.com
[INFO] ----------
[INFO]

Jenkins build fails no error

I am quite new when it comes to Jenkins and I am trying to setup a continuous integration environment for our workspace. I am running Jenkins locally on a Windows client - solely for testing purposes - but cannot seem to find the error that is causing the build to fail. All I want to do is trigger an automatic build that will compose the .war file.
Here is the generated output from Jenkins:
<===[JENKINS REMOTING CAPACITY]===>channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f C:\Program Files (x86)\Jenkins\jobs\POSIOS\workspace\XudoxWS\src\main\XudoxWS\pom.xml mvn install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XudoxWS WebServer 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.116s
[INFO] Finished at: Mon Oct 14 18:22:33 CEST 2013
[INFO] Final Memory: 7M/154M
[INFO] ------------------------------------------------------------------------
I can confirm that I can locally build the project without any issues. I am using Maven.
Thanks in advance for your offered help.
Seems like you've set the following as goals and options:
mvn install -Dmaven.test.skip=true
You shouldn't include the mvn executable, then it'll work just fine.

How do I create a debuggable build in jenkins using a pom file?

I am trying to build a robotium apk file that can execute test cases automatically from jenkins and receive the following error:
[INFO] Run started: se.stuff.android.app.test, 7 tests:
[INFO] Start: se.stuff.android.test.app.APP_Test#test_A_check_app
[INFO] End: se.stuff.android.test.app.APP_Test#test_A_check_app
[INFO] Start: se.stuff.android.test.app.APP_Test#test_B_bad_credentials
[INFO] End: se.stuff.android.test.app.APP_Test#test_B_bad_credentials
[INFO] Start: se.stuff.android.test.app.APP_Test#test_C_Log_in
[INFO] ERROR:se.stuff.android.test.app.APP_Test#test_C_Log_in
[INFO] Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang.ClassNotFoundException''. Check device logcat for details
[INFO] End: se.stuff.android.test.app.APP_Test#test_C_Log_in
[INFO] Run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
[INFO] Run ended: 0 ms
[ERROR] FAILURES!!!
[INFO] Tests run: 3 (of 7), Failures: 0, Errors: 1
[INFO] Report file written to /var/lib/hudson/jobs/App_Android_Test/workspace/APP_Test/target/surefire-reports/TEST-localhost_49851_unknown_sdk.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
I checked the emulator and seem to be missing the InstrumentationTesRunner. What I have heard is that instrumentation classes are excluded when an application is built for release. My question is therefore, how do I create a debuggable build in jenkins using a pom.xml file and building with maven?
The two first test cases can actually pass with nothing happening since it's supposed to check that everything is ok before start. If it doesn't find potential issues will the test execution just continue.

Hudson: Builds of multi-module maven project fail, then immediately succeed again

I have a multi-module project where the top level project serves both as the parent of the individual modules and as the project that declares the modules. Only this top level project is configured in Hudson (including automatic SVN checkout). The simplified layout is as follows:
ProjectRoot\
|
+---kernel\
| |
| +---pom.xml [ArtifactId=MyProject_kernel parent=MyProject]
|
+---model_foo\
| |
| +---pom.xml [ArtifactId=MyProject_model_foo, parent=MyProject]
|
+---pom.xml [ArtifactId=MyProject, parent=none]
Also, model_foo has a dependency on kernel.
Now, Hudson automatically discovers the kernel and model_foo sub projects, and it usually manages to build everything just fine.
However, each time I make a breaking change, such as create a new class in kernel and use it inside model_foo, I get a failing build for model_foo, followed by one that succeeds. The mail notifications are titled
Build failed in Hudson: MyProject » MyProject Model Foo #1545
Hudson build is back to normal : MyProject » MyProject Model Foo #1546
Why is that? I suspect it might have to do with the fact that the MyProject pom.xml is both the multi-module project and the parent of its modules, but before changing that I would like to know whether it's actually going to help.
I use Hudson 2.1.0.
Update
This is the log of a failed build of the web module (equals model_foo in the diagram above). The build for the MyProject root project had the same build number, and succeeded.
I stripped out the actual compiler errors, which are exactly the same as if the newly introduced class was missing.
Started by upstream project "MyProject" build number 1545
Found mavenVersion 2.0.9 from file jar:file:/home/builder/opt/apache-maven-2.0.9/lib/maven-2.0.9-uber.jar!/META-INF/maven/org.apache.maven/maven-core/pom.properties
$ /home/builder/opt/jdk1.5.0_22//bin/java -Xmx1024m -Xms512m -cp /home/builder/var/hudson/plugins/maven-plugin/WEB-INF/lib/maven-agent-2.1.0.jar:/home/builder/opt/apache-maven-2.0.9/boot/classworlds-1.1.jar hudson.maven.agent.Main /home/builder/opt/apache-maven-2.0.9 /home/builder/opt/apache-tomcat-6.0.24/webapps/hudson/WEB-INF/lib/hudson-remoting-2.1.0.jar /home/builder/var/hudson/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-2.1.0.jar 48555
<===[HUDSON REMOTING CAPACITY]===> channel started
Executing Maven: -N -B -f <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/pom.xml> clean deploy -Dworkspace.path=/home/builder/var/hudson/jobs/MyProject/workspace/ -Droot.project.name=MyRoot -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject
[INFO] task-segment: [clean, deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/target>
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 945 source files to <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/target/classes>
[HUDSON] Archiving <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/pom.xml> to /home/builder/var/hudson/jobs/MyProject/modules/com.mycompany.myproject$web/builds/2011-09-27_13-32-33/archive/com.mycompany.myproject/web/1.1-SNAPSHOT/pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
{{{compiler failure here}}}
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:579)
{{{stacktrace omitted}}}
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
{{{stacktrace omitted}}}
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 7 seconds
[INFO] Finished at: Tue Sep 27 13:33:42 CEST 2011 [INFO] Final Memory: 53M/508M
[INFO] ------------------------------------------------------------------------

Resources