Jenkins doesn't recognize Allure command - maven

Hello Allure generators,
I'm trying to make Allure accessible to our testers in the company. I've installed Allure 2 through Scoop in the server and I'm able to run the cmd script: "allure serve" and see the results. So far so good. Now, my basic thought for solution is : run a "Post build actions" with a "Post build tasks" plugin with the allure serve command. The result is not good:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.801 s
[INFO] Finished at: 2018-06-25T11:08:28Z
[INFO] ------------------------------------------------------------------------
Performing Post build task...
Match found for : : True
Logical operation result is TRUE
Running script : cd C:\Projects\CarambolaClientTest2\target
allure serve
[Suite_runner] $ cmd /c call C:\Windows\TEMP\jenkins6058556997605873748.bat
C:\Program Files (x86)\Jenkins\workspace\Suite_runner>cd C:\Projects\CarambolaClientTest2\target
C:\Projects\CarambolaClientTest2\target>allure serve
'allure' is not recognized as an internal or external command,
operable program or batch file.
C:\Projects\CarambolaClientTest2\target>exit 9009
POST BUILD TASK : FAILURE
How can it be that "'allure' is not recognized.." ? It recognized it through the cmd (I've added it to the Environment variables of the machine and also to the environment variables in Jenkins configuration under Global properties).
I've also tried:
Create a Batch file with the script and run it in the post build
task (got the same result).
Add the Allure Plugin- but that's a
whole new problem- I'm getting an empty report.
Create new Job that only runs a "Windows batch command" with the allure serve, and it is running "Down stream" after the main Job runs (its the 2nd
project). Getting the same result.
Any ideas?
Thanks

You don't have allure executable in your PATH. Try to reload jenkins slave (or master) to see changes if you've added it to PATH before.
Also you can make Jenkins install allure automatically - find the a plugin for that

Related

Get NOT_BUILT build result in Jenkins when building maven project with selective dependencies

I have a multi-component maven project in Jenkins. This project has a Send Files over FTP Post-Build step. I have set my mvn goals to build just my desired component; not all of them:
clean install -pl component-x,component-y -P develop -X
All the dependencies in my project are built successfully;
[INFO] component-x ............................ SUCCESS [ 5.026 s]
[INFO] component-y ............................ SUCCESS [ 16.912 s]
but the Jenkins says:
FTP: Current build result is [NOT_BUILT], not going to run.
EDIT 1:
Yes, I have read this issue. People suggestions include:
Do it manually.
Use Execute Shell instead.
But there were no solution for How to do it manually.
BTW I have an FTP server which I want to put files on; it's not possible for me to use Execute Shell.
Looks like because of this bug https://issues.jenkins-ci.org/browse/JENKINS-16240
Either you can set the status to success manually or use execute shell for ftp instead of the plugin.
You can run a post build groovy script manager.buildSuccess()
See here
The problem is, that the Publish over FTP plugin checks if the build was successful. Unstable is accepted, too, but NOT_BUILT isn't. If the build is not considered successful, the plugin refuses to run.
It is arguable, if that is an expected behavior. The user might want to transfer files, even if the build was not successful. Besides, the NOT_BUILT obviously refers only to the last build step, not to the overall result which is still SUCCESS.
There is an issue filed under JENKINS-55816.
I've created a patch that does not check for the build result which can be downloaded from here (use at your own risk, with no warranty whatsoever).

build failure Jenkins+Maven+SVN

Started by user xxx
Building in workspace C:\Users\Vinay.jenkins\workspace\Orbit App Automation
Updating https://polarisdev.svn.cloudforge.com/qaautomation at revision '2017-12-01T11:04:13.362 +0530'
Using sole credentials xxxx/****** in realm ‘https://polarisdev.svn.cloudforge.com:443 CloudForge login’
At revision 5
No changes for https://polarisdev.svn.cloudforge.com/qaautomation since the previous build
[qaautomation] $ cmd.exe /C "D:\apache-maven-3.5.0\bin\mvn.cmd -f pom.xml '"-Dmaven.repo.local=C:\Users\Vinay.jenkins\workspace\Orbit App Automation.repository"' clean install && exit %%ERRORLEVEL%%"
POM file pom.xml specified the -f/--file command-line argument does not exist
Build step 'Invoke top-level Maven targets' marked build as failure
Sending e-mails to: vinaya.mopidi#orbitanalytics.com
Finished: FAILURE
It is working now ,earlier i have given incorrectly Repository URL (svn url) now given up to svn work space
Correct : https://xxxx.svn.xxx.com/qaautomation/xxxAutomation
InCorrect : https://xxxx.svn.xxx.com/qaautomation
Build step 'Invoke top-level Maven targets' marked build as failure because you entered your shell script in maven goals and options input field.
You command seems to be a free style windows command script .
cmd.exe /C "D:\apache-maven-3.5.0\bin\mvn.cmd -f pom.xml '"-Dmaven.repo.local=C:\Users\Vinay.jenkins\workspace\Orbit App Automation.repository"' clean install && exit %%ERRORLEVEL%%
Select the execute windows batch command radio button in the build step.

Maven wrapper in jenkins

I'm trying to test build a maven based project in jenkins.
https://github.com/tonsV2/Lift-Log-Backend
However I get the following error.
[Lift Log Backend] $ /bin/sh -xe /tmp/hudson4180120395829748105.sh
+ ./mvnw clean
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Any clues?
Seems like you have spaces in your Jenkins job name. Try to rename your job from "Lift Log Backend" to "Lift-Log-Backend"
I had the same issue, after renaming the Jenkins job, the error was gone.

Unable to execute maven command on jenkins

I have a jenkins job that checks out code from TFS and executes a test class using testng.xml
I have Maven properly installed in my machine in C:\JenkinsDependencies\apache-maven
It has mvn.bat file in its bin folder.
But when I execute my job, it fails with the following error.
Checking for pre-build
[TFS_LN_Mobile] $ cmd.exe /C '"C:\JenkinsDependencies\apache-maven\bin\mvn.bat test && exit %%ERRORLEVEL%%"'
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Build step 'Invoke top-level Maven targets' marked build as failure
Checking for post-build
Finished: FAILURE
Below is the configuration of my jenkins job:
I manually executed a batch command as follows:
cd "C:\JenkinsRoot\workspace\TFS_LN_Mobile"
mvn test -DsuiteXmlFile=testng.xml
This works fine.
mvn.bat is a batch script. you can try adding trace of it's variables after steps that might produce this error. take a look at this: Is there any way to trace through the execution of a batch file?

How does Hudson/Jenkins determine job result status?

I have a Hudson server that runs maven 3 jobs to compile Java code. In one instance, a particular job's build log indicates that the compilation and unit tests all ran successfully, and the build completed in a successful state and another chained job was called, all indicated that Hudson believed the job to be successful. The log shows:
20:44:11 [INFO] BUILD SUCCESS
20:44:11 [INFO] ------------------------------------------------------------------------
20:44:11 [INFO] Total time: 1:35:43.774s
20:44:11 [INFO] Finished at: Mon Mar 24 20:44:11 CDT 2014
20:44:40 [INFO] Final Memory: 51M/495M
20:44:40 [INFO] ------------------------------------------------------------------------
20:44:42 channel stopped
20:44:42 [locks-and-latches] Releasing all the locks
20:44:42 [locks-and-latches] All the locks released
20:44:43 Archiving artifacts
20:45:33 Updating JIRA-1234
20:45:33 Description set: 1.23.567
20:45:33 Labelling Build in Perforce using ${BUILD_TAG}
20:45:33 [jobname] $ /usr/local/bin/p4 -s label -i
20:45:33 Label 'hudson-jobname-45' successfully generated.
20:45:33 [DEBUG] Skipping watched dependency update; build not configured with trigger: jobname #45
20:45:33 Finished: SUCCESS
However, the Hudson job page shows a "red ball" and that job run is listed as "Last failed build (#45)" on the job page. When I look at the hudson#hudson:~hudson/jobs/jobname/builds/45/build.xml file, there is a line that says
<result>FAILURE</result>
Assuming this was where the final result was captured, I changed this to
<result>SUCCESS</result>
and reloaded the page, but the red ball is still showing on the job page for that instance. I have not restarted the server to attempt to re-read the info from disk.
To be fair, there were some environmental issues around this build. Some hours later, I got a message that more than one Hudson server instance was running against the same disk image and confirmed this with
ps -ef | grep hudson.war
on the server console, showing two running processes. The job page says this run "Took 0 ms", even though the log says "Total time: 1:35:43.774s". This is Hudson ver. 2.2.1 running on "CentOS release 5.4 (Final)".
My questions:
What are the criteria for each of the job statuses? (Stable, Failed, Unstable, Aborted and Disabled statuses)?
When and where is that data captured in the running server, and can it be modified?
You have too many questions in one post.
As for "What are the criteria for each of the job statuses? (Stable, Failed, Unstable, Aborted and Disabled statuses)?"
Disabled is when a project/job is disabled from configuration (done by user with permissions). This is not a run status.
The rest are Job Run statuses:
Aborted is when a run has been cancelled/aborted. This happens when a user (with permissions) clicks the red cross button to cancel a running build. I believe SCM checkout failure also causes aborted status (but not too sure about that)
Unstable is a special status that can be applied to the job run. Usually this is done by job configuration (such as Maven) or through plugins such as Text-finder plugin. I am not aware of a way to induce unstable status through command line. Maybe through a groovy script, like plugins do. Most of the times, unstable is set by the job configuration itself, indicating failed test.
Stable and Failed are the direct result of Build Step's exit code. If the build step, such as Execute Shell, exits with exit code 0, the build step is considered success. Anything other than 0 is considered failed. If during execution of a build step, the process exits with anything other than 0, it is considered failed. If there are multiple build steps (Free-style project jobs), the last Build Step's exit code marks the status of the whole run. Once again, any Build Step in between that exits with anything other than 0 will mark the build failed.
Post-build actions, such as Text-finder plugin can also change the status of the job run.
You are not supposed to be tinkering with job history files to change the status of previous jobs. If you need to change the job result, use post-build actions such as Text-finder plugin, but even then, it only allows to downgrade the result.
Here's a one liner to printing the commit SHA1 in a jenkins job using groovy post-build script:
println "git rev-parse HEAD".execute().text
You can save this to a variable or export it as a build parameter.

Resources