Output Bazel test generated file to Jenkins - jenkins

I am running CI/CD with Bazel and Jenkins. After the test complete, I want to upload some output files to source control. I am looking for a way to output the files generated by Bazel to Jenkins. I tried to use TEST_UNDECLARED_OUTPUTS_DIR, it can output a outputs.zip file when I run bazel test locally. But when it comes to triggering the test with Jenkins, I can't find the file under bazel-out.

Related

Jenkins - Selenium : Trying to get access to testng failed.xml.? Where will this file be located when scripts are ran through jenkins

Currently it consumes so much time to rerun the filed test cases from Jenkins in My LOCAL MACHINE.And most of the test would pass locally .
Is there anything I can do to cut short the time ?
TestNG generates all of the artifacts viz.,
Html reports
Emailable report
JUnit styled xml reports
TestNG XML reports
testng-failed.xml
by default in the output directory of your project. If its not defined, TestNG defaults to test-output folder.
When tests are run via build tools such as maven wherein you leverage the surefire plugin, then this output directory gets configured to point to target/surefire-reports directory.
So your testng-failed.xml if it gets generated, will be available in your $WORKSPACE\target\surefire-reports directory (Here $WORKSPACE represents your Jenkins job's workspace)

Jenkins fails to find SureFire Reports

Jenkins Version : 2.176.2
Executing Selenium tests via Jenkins : Ecplsie+mvn+Jenkins
Selenium Workspace Folder : C:\Users\admin\eclipse-workspace\ACA
The actual location of the testng-results.xml: C:\Users\admin\eclipse-workspace\ACA\target\surefire-reports\testng-results.xml
Jenkins Insatlled / Home Directory: C:\Program Files (x86)\Jenkins
Building in workspace C:\Program Files (x86)\Jenkins\workspace\ACATestAutomationJob
Executing Maven: -B -f C:\Users\admin\eclipse-workspace\ACA\pom.xml clean install
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/target/surefire-reports/testng-results.xml
Did not find any matching files.
How do i make jenkins locate this testng-results.xml?
Thanks,
Raj
Look into Jenkins Console Output, it should report where the build is running (so called WORKSPACE) and where TestNG Results Plugin attempts to locate the results file:
The path to the TestNG results file must be relative to the WORKSPACE and have the syntax of Ant FileSet
If you're uncertain regarding how to properly build the path to the test artifacts - post the full paths to WORKSPACE and the testng-results.xml / emailable-report.html and we will help you to come up with the correct definitions.
In the meantime you could use wildcard paths like:
**/testng-results.xml
so Jenkins will scan its WORKSPACE recursively looking for the testng-results.xml file in all available locations
Your install command also looks suspicious, normally you should not be putting your test artifacts to the Maven repository so you might want to use mvn test or mvn verify instead.
More information:
Turbo Boost Your Digital App Test Automation with Jenkins
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Jmeter with ant - reports creation

I am trying to create report using ant in jmeter, meaning the full report.
I downloaded ant and it is installed as expected.
first I want to understand if ant command need to perform after test plan ran in the past? meaning it is offline process that creates the html reports? after the test plan finished?
Or is it command that actually used to run the test plan and create the html, meaning I do not need to run jmeter before?.
I used this command
jmeter -n -t C:\JMETER\Framework\Test_Fragment\Kung_Fu.jmx -l C:\Users\stackoverflow\Desktop\Jmeter_reports\results22_05_2018.csv
to run jmeter from command line, and create csv, so do I need two commands? one for creating csv and one for the ant? and if I create the csv where can I find the jtl of the testplan.
Name of test plan kung_fu
name of csv results22_05_2018.csv
what are the processes to run he ant, since I rename the Kung_Fu.jmx to test.jmx and put it in extras folder and when I command ant, it says test.jtl is not found.
can someone give a full explanation about the whole process
Rename results22_05_2018.csv into results22_05_2018.jtl and copy it to "extras" folder of your JMeter installation
Execute the following command in "extras" folder of your JMeter installation:
ant -Dtest=results22_05_2018 xslt-report
HTML report will be available as results22_05_2018.html
For more details see:
build.xml - reference Ant build file, by default it:
looks for Test.jmx file in the current folder
executes it and stores the result into Test.jtl file
applies XSLT transformation to the Test.jtl file and generates HTML file out of it.
JMeter Ant Task
Five Ways To Launch a JMeter Test without Using the JMeter GUI

How does the Jenkins Cobertura plugin operate to enable source code viewing?

I'm trying to get a build in Jenkins to show a coverage report of a Java unit test run. I can get the report at the high level showing that coverage has occurred at the class and method level, but part of the report where I can view the source code isn't working.
The inputs to the plugin are:
a coverage report in XML
source code
To use the plug in to create a coverage report:
Install Cobertura into Jenkins.
Create a Jenkins job with a post build to generate Cobertura report. In this step you tell it where in the Jenkins workspace to load the coverage report (often named coverage.xml).
Before you run the Jenkins job
The coverage report is created in some way (often by a build script of some kind). The report is often named coverage.xml by most people's build scripts and is placed in the Jenkin's job's workspace.
When running the Jenkins job
When the Jenkins job runs, the Cobertura plugin will read the coverage.xml and use the element to locate the source code. The plugin copies the source code into a cache located at: <Jenkins home>/jobs/<Jenkins job name>/<Cobertura>.
After running the Jenkins job
Read the coverage report by navigating to the Jenkins job that built it. If copying of the source files was successful during running the Jenkins job, you can drill down to the source code and see what lines were covered by the test run. If you can't see the source code level code coverage:
Check the cobertura cache to see if the code is there.
Check the permissions on the cache to see if the Jenkins server process owns that directory and has read, write, execute permission on that directory.
Check the cobertura.xml file and select a element and examine it's "filename" attribute and see if it's path will work as a relative path from the root of the Cobertura cache.
If the cache has old information, delete everything in the cache directory, and re-run the Jenkins job.

Qunit + JSCoverage + Jenkins

I have started using Qunit to test my JS code. I am looking into JSCoverage to generate the coverage reports later. We have a CI server (Jenkins) which already do a few things with our PHP code and I was wondering if anyone can comment on how I can integrate the report from my Qunit and JSCoverage into Jenkins
Thanks
Sparsh
QUnit: use QUnit API to generate junit XML files. Here's a sample.
In Post-build Actions for your job you then check Publish JUnit test result report and specify your junit XML files (or their file pattern). Jenkins will then mark builds that have failed tests as unstable and produce a nice trend graph of successful/failing tests.
A few more details, for those actually attempting this:
Putting together QUnit and Jenkins
If you want to run QUnit and publish the results in Jenkins, you'll need to do the following:
Step 1: Getting QUnit to generate an XML file compatible with JUnit.
If you're using Apache Ant, this question explains how to get
QUnit to generate XML.
If not, you can use Grunt and
grunt-qunit-junit, together with grunt-contrib-qunit, to
run your .html tests.
And if you're not into either Ant or Grunt, here is
a script for PhantomJS to run your tests directly and produce
JUnit-style XML.
Step 2: Processing that XML file
This is the easy step - look in "Post-build Actions" for your job in Jenkins, and add the path to the XML file.

Resources