Allure: Jenkins Plugin is not able to generate report - jenkins

Could you please help with the follow?
Running the protractor test.
Jenkins plugin is not able to generate report.
Error: 404 not found.
Allure plugin: 2.19
Allure commandline: 1.54
Protractor: 5.1.2
Jenkins is run locally: 2.60.1
NodeJS: 6.9.4
NPM: 4.0.5
Error stack trace: allure-report for the report is already in use, add a '--clean' option to overwrite.
Stack trace:
[11:56:19] I/launcher - 0 instance(s) of WebDriver still running
[11:56:19] I/launcher - chrome #01 failed 1 test(s)
[11:56:19] I/launcher - overall: 1 failed spec(s)
[11:56:19] E/launcher - Process exited with error code 1
npm ERR! Test failed. See above for more details.
Build step 'Execute Windows batch command' marked build as failure
[protractor-allure-reporting-example] $ D:\Jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\allure-commandline\allure-2.2.1\bin\allure.bat generate
D:\Jenkins\workspace\protractor-allure-reporting-example\first-result -o
D:\Jenkins\workspace\protractor-allure-reporting-example\allure-report
Allure: Target directory D:\Jenkins\workspace\protractor-allure-reporting-
example\allure-report for the report is already in use, add a '--clean' option to overwrite
ERROR: Build step failed with exception ru.yandex.qatools.allure.jenkins.exception.AllurePluginException: Can not generate Allure Report, exit code: 1
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.generateReport(AllureReportPublisher.java:173)
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.perform(AllureReportPublisher.java:94)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
at hudson.model.Run.execute(Run.java:1760)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Build step 'Allure Report' marked build as failure
Finished: FAILURE

Seems like you need to clean your workspace before build. Or you can add one more step before report generation that will remove allure-report directory.

Add it in package.json scripts
"posttest": "allure generate allure-results --clean -o allure-report || true && allure report open -o allure-report"

try to check that in the docker container where your allure report generated not able to detect java_home. So try to set your report path where your container ends and then your allure report will able to find java_home.
and able to generate report.
Use below command to check the same:
sh "/var/lib/.../ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/../bin/allure --version"

Related

Protractor: Jenkins won't build project locally (mac)

As I'm trying to run a sample jenkins project from my machine. However, I it won't build my project locally.
I outline the set up in this jing video
What did I do wrong?
What specific steps should I use to fix it.
Error message from jenkins
Started by user Jacqueline George
Building in workspace /Users/jacquelinegeorge/.jenkins/$(JENKINS_HOME)/LocatorTraining
[LocatorTraining] $ cmd /c call /var/folders/2s/d8lh31wd3_7dx65htqzvpcv80000gn/T/jenkins6260102670441278278.bat
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Caused: java.io.IOException: Cannot run program "cmd" (in directory "/Users/jacquelinegeorge/.jenkins/$(JENKINS_HOME)/LocatorTraining"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:249)
at hudson.Proc$LocalProc.<init>(Proc.java:218)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:935)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1819)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Build configuration
How I am executing the build
Code after using npm run protractor in shell
Started by user Jacqueline George
Building in workspace /Users/jacquelinegeorge/.jenkins/$(JENKINS_HOME)/LocatorTraining
[LocatorTraining] $ /bin/sh -xe /var/folders/2s/d8lh31wd3_7dx65htqzvpcv80000gn/T/jenkins563599888073808645.sh
+ npm run protractor
npm ERR! path /Users/jacquelinegeorge/.jenkins/$(JENKINS_HOME)/LocatorTraining/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/jacquelinegeorge/.jenkins/$(JENKINS_HOME)/LocatorTraining/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jacquelinegeorge/.npm/_logs/2018-11-13T10_38_04_562Z-debug.log
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I made a modification to the build. I selected 'shell' (as I'm a mac user) not windows batch (as my tutor instructed). I also removed customer workspace from my configuration
Added the following command in 'build'
/Users/JacquelineGeorge/Documents/Jenkins/LocatorTraining&&npm run
protractor
It still failed but this message was at least different.
I also tried this with and without ${JENKINS_HOME} under
General>Advanced>use custom workspace
Building in workspace /Users/jacquelinegeorge/.jenkins/workspace/Protractor
[Protractor] $ /bin/sh -xe /var/folders/2s/d8lh31wd3_7dx65htqzvpcv80000gn/T/jenkins8556486662152409824.sh
+ /Users/jacquelinegeorge/Documents/Jenkins/LocatorTraining
/var/folders/2s/d8lh31wd3_7dx65htqzvpcv80000gn/T/jenkins8556486662152409824.sh: line 2: /Users/jacquelinegeorge/Documents/Jenkins/LocatorTraining: is a directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The failure is due to you choose build step of Execute window batch command. But your Jenkins slave machine (where your test script resides) is a linux.
You should choose Execute shell for that build step.
Ok, I'm going to to do a summary of this conversation.
From your project page select configure
Scroll down to build
Under build select shell
enter cd /Users/YourUserNameHere/YourProjectWorkSpace/ProjectFolder/FileName&&npm run protractor
Save
When you click build now. Your project should now build locally from your machine.

allure-results does not exists in Jenkins

Allure results are generated (xmls) and can be viewed by running allure serve outside the allure-results directory but when configured in Jenkins using the allure results directory with relative path from Jenkins workspace, the allure results are not found. Presumably there is something wrong with the path
[allure_test] $ /Users/me/.jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_2.7.0/bin/allure generate -c -o /Users/me/.jenkins/workspace/allure_test/allure-report
allure-results does not exists
Report successfully generated to /Users/me/.jenkins/workspace/allure_test/allure-report
Allure report was successfully generated.
Relative Path defined for allure report is
../../repos/partner-portal/target/allure-results
The report is generated but with no results
Here is the solution:
1. Inside your work space (For me it is D:\m\Automation Project\Tests), Create a folder named "target" containing two subfolders "allure-results" and "allure-reports".
In Post Build Actions of Jenkins Project provide these entries.
Results: target/allure-results
Report Path: target/allure-reports
Now run your tests and allure reports will be generated without any issues.
I struggled for over 24 hours and could not sleep whole night just because of this issue. There were no clear instructions related to this and how it works. Finally, I figured it out.
May be its little too late for this answer but could you please create the "allure-results" folder in your workspace (like /Users/me/.jenkins/workspace/allure_test/allure-results)?
After I configure Allure report in jenkins, and using behave command, I finally see following output and saw the working report in my jenkins build plan:
.
.
.
.
D:\PythonProject\PythonBehave>behave -f allure_behave.formatter:AllureFormatter -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-results D:\PythonProject\PythonBehave\features
Failing scenarios:
features/example.feature:17 user can search text in google -- #2.2 Incorrect
features/github_login.feature:13 User attempt to login with wrong username and password -- #1.1 InCorrect
features/github_login.feature:14 User attempt to login with wrong username and password -- #1.2 InCorrect
features/github_login.feature:18 User attempt to login with correct username and password
0 features passed, 2 failed, 0 skipped
3 scenarios passed, 4 failed, 0 skipped
12 steps passed, 4 failed, 8 skipped, 0 undefined
Took 3m24.651s
D:\PythonProject\PythonBehave>exit 1
Build step 'Custom Python Builder' marked build as failure
[PythonAllure] $ C:\Users\Alex\.jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\Allure_2.13.1\bin\allure.bat generate C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-results -c -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
Report successfully generated to C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Finished: FAILURE
And before I used to get this output when there was no allure-results folder in my workspace:
[PythonAllure] $ C:\Users\Alex\.jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\Allure_2.13.1\bin\allure.bat generate -c -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
we are not using any post-build steps on UI but using jenkins pipeline groovy script as below:
def allureReportsGenerationTask() {
try {
allure([includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'target/allure-results']]])
} catch(Exception error) {
println("Caught Exception: ${error}")
}
}
The project structure was like that only
ProjectRepo
- src
- target
-alure-results
- pom.xml
- testng.xml
In this case, we are getting the allure-results getting generated but it was not getting picked in the Jenkins pipeline allure plugin. ON UI below command was running always
/opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
you can see Jenkins was not able to find allure-results for generating parameters in the above Jenkins pipeline command
We added the below parameter in pom.xml maven-surefire-plugin
<systemPropertyVariables>
<allure.results.directory>../target/allure-results</allure.results.directory>
</systemPropertyVariables>
Now project structure becomes
-ProjectRepo
- src
- pom.xml
- testng.xml
target
-allure-results
Now on running the same via pipeline script, we were able to run the below command
/opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate /opt/jenkins/workspace/ProjectRepoPipeline/target/allure-results -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
ProjectRepoPipeline - This is the Jenkins pipeline name that is running CI/CD

Allure report in Jenkins does not load and it shows the loading on browser

I have used allure report in my framework for reporting.
After completion of test scripts on Jenkins and clicking allure report icon, it does not load the reports it show loading.
Allure Jenkins Plugin version = 2.10
Following is the Jenkins console output:
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project com.fa.ipsy: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/Edu/jenkins/workspace/Appium_android/target for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Execute shell' marked build as failure
[Appium_ipsy_mobile] $ /Users/Edu/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/1.4.23.HOTFIX1/bin/allure generate "/Users/Edu/jenkins/workspace/Appium_android/target/allure-results" "/Users/Edu/jenkins/workspace/Appium_android/allure4208353174449196512.tmp/environment" -o "/Users/Edu/jenkins/workspace/Appium_android/allure4208353174449196512.tmp/allure-report"
Report successfully generated to the directory </Users/Edu/jenkins/workspace/Appium_android/allure4208353174449196512.tmp/allure-report>. Use `allure report open` command to show the report.
Finished: FAILURE
Thank you for the Help
The Issue is resolved now, we are able see the Allure HTML reports.
We have updated our Allure Jenkins plugin Version (2.10) to 2.26.0.
Thanks

Permission denied while running maven command jenkins

I am facing permission denied issues while running a maven clean test on a pom.xml present in /home/tes/pom.xml from jenkins. Any suggestions
Building in workspace /var/lib/jenkins/workspace/jenkins
[jenkins] $ /usr/share/maven/bin/mvn -f /home/tes/pom.xml clean test
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project (/home/tes/pom.xml) has 1 error
[ERROR] Non-readable POM /home/tes/pom.xml: /home/tes/pom.xml (Permission denied)
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
Just grant read access for all to the pom.xml file:
chmod +r /home/tes/pom.xml
The moderator has deleted my previous answer; I know that it has passed some time since this first post, but I ended up exactly in the same place. I insist in complementing all the answers because I've found what was the problem in my case,having the same result as reported in this case.
I'd like to comment that, in my case, the reason was that I did not have JDK, but just JRE configured in JAVA_HOME of the Global Tool Configuration > JDK > JDK Installation. As a matter of fact Jenkins warns you that the path is not pointing to something containing a JDK.
JDK is needed for some Plugins, like Maven Integration or Docker Pipeline, as Java requirements section in Jenkins documentation states. So this must checked because it surprisingly results in the weird error:
> git rev-parse refs/remotes/origin/celsus_0-1-0^{commit} # timeout=10
Checking out Revision 0c533cf2327a416a254afa2348abafe7790ba67f (refs/remotes/origin/celsus_0-1-0)
> git config core.sparsecheckout # timeout=10
> git checkout -f 0c533cf2327a416a254afa2348abafe7790ba67f # timeout=10
Commit message: "first embrio of container image"
> git rev-list --no-walk 0c533cf2327a416a254afa2348abafe7790ba67f # timeout=10
Parsing POMs
Established TCP socket on 40251
[build] $ /usr/lib/jvm/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/usr/share/maven/boot/plexus-classworlds-2.x.jar:/usr/share/maven/conf/logging jenkins.maven3.agent.Maven35Main /usr/share/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-4.5.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 40251
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "/usr/lib/jvm/bin/java" (in directory "/var/lib/jenkins/workspace/build"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:802)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
at hudson.model.Run.execute(Run.java:1907)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 13 more
Finished: FAILURE
Similar case as originated this case, as the different nature of the solutions proposed points out. I'd like to bring the attention that these errors having to do with permissions, or parsing of the pom might hide the real root cause, and error messages are not always as explicit and clear as they should be.
Hope it helps others bumping into the same issue.
I installed maven plugin for jenkins and provided the fully qualified path of pom.xml in root pom.xml and it fixed the issue
I think the reason this happens is maven has the right to run pom.xml ie. mvn command can be run through terminal but not through jenkins.
So we will need to add the current user to jenkins for it to work.
Follow this blogpost. It worked for me:
blogpost

ant build failes on Jenkins

When I start the Jenkins build, on arriving on ant-build-step the build is canceled immediately with the following stack:
...
[PROJECT] $ cmd.exe /C "D:\jenkins\tools\hudson.tasks.Ant_AntInstallation\Ant\bin\ant.bat -file build-jenkins.xml -Djenkins.result.dir=${JENKINS.WORKSPACES}/Results "-Dbranch=*/develop" -Djenkins.result.dir=C:/Tools/Jenkins/Results -Djenkins.workspace.dir=C:\Tools\Jenkins\Project-SNAPSHOT\workspace/PRO_56/PRO/java/Project -Dproject.path=C:\Tools\Jenkins\Project-SNAPSHOT\workspace clean.compile.jar.server.snapshot -v && exit %%ERRORLEVEL%%"
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
...
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
I get no debug messages, nothing.
I've got other project with a similar/equal config which work. I think it could be a incompatibility of my plugins.
Has anyone experienced this bug before?
In my case the problem was a big M in the java options of the ant-build-step.
Here no m for Megabit und M für Megabyte.
-Xmx1024M
-Xms1024m

Resources