I would like to use Jenkins for continues testing. Job scenario should look like: 1. connect to svn, call scripts to check-out repo, build and run test. Test will e.g. check if numbers in some output file are same as in reference file. All scripts are in python. The question is - how to force Jenkins to indicate job as "Fail" when numbers in files are different?
Thanks in advance
Typically you would use Jenkins a little differently. It is possible to do exactly what you want but Jenkins and python can eliminate some work for you.
First, Jenkins has the capability to check out stuff from various version control systems, including Subversion. This is the usual way to use Jenkins. When you set up a job, you tell the address of your version control repository and after that you configure the steps to execute after the files have been checked out.
Second, you should use the python test framework http://docs.python.org/library/unittest.html to write your tests. Then you can use e.g. nosetests utility to run the tests. Nosetests can even create test reports in xml format and Jenkins can read the reports and show you which tests failed and why they failed (if the report includes that information.)
But to answer your question: If you exit the build step with non-zero exit code, Jenkins will interpret that to mean the build failed and it will mark that build with a red ball.
Jenkins can mark builds as stable (green), unstable (yellow) and failed (red). If the build step exits with non-zero exit code, the build has failed. If the build step exits with zero, Jenkins can be configured to look for test report files. If the test reports have failed tests, the build will be unstable. If all the tests have passed, the build is stable.
Usually people use the failed (red) to indicate a fatal problem in the test (e.g. failure to install the software that should be tested) and then use test reports to indicate unstable or stable build.
Related
I created a freestyle project in jenkins, in which I chose source code management as git, screenshot below
That's pretty my config. The repo you see in there is public repo. then I save the config, then I click build now.
It seems to works base on the notification on screen, which says 'success'. But I have no idea I what the heck Jenkins produced. I didn't instruct what to build and how to build. How does it know what I want? And lets say it did build something, where does it store the build? I didn't instruct it where to store the built file either. Can someone explain what is going on?
To actually build something you need to add something to your Build section in the project configuration. For a javascript configuration it might look something like:
npm install
npm run test-coverage
npm run linter
npm run complexity
where each item after run is a script in your package.json. Then you can add plugins to read the outputs of those actions, for example:
Clover test coverage publisher
TAP (Test) results publisher
HTML Publisher for publishing static analysis results
Checkstyle publisher for linting results
This allows you to pass and fail builds based on certain test criteria and where continuous integration starts to shine.
In Jenkins job you have several sections - you can define pre build actions to prepare the environment, SCM to check out from source control, Build section to run your build pipeline and post build operation to run actions after the build section.
If you defined only the SCM section all your job did is to check out your sources from the source control you provided. the status of this action is SUCCESS.
Don't forget to check the console output of the job that ran to see which steps ran.
For GUI testautomation we have set up a Maven project using JBehave (v4.0.4) as a BDD framework. The stories are executed with a JUnitReportingRunner and run continously in a Jenkins (v1.630) master slave environment.
I recently noticed that in some cases, the Jenkins build is marked as successful despite some failed steps. The XUnit test report correctly indicates that there is a failed test while the Jenkins build does not. We haven't configured any thresholds concerning the build status. Therefore one failed test should cause the build to fail (and it does most of the time).
This problem is very annoying since we heavily rely on the Jenkins mail notifications. Any pointers on how to solve it are very much appreciated.
I'm working on a team that is building a RESTful HTTP service. We're having trouble with setting up a Jenkins CI job which will build the service, run it in the background, execute some tests, and then terminate the servers.
Specifics
The server is built in Node.js using the hapi framework and has some unit tests written in mocha.
The tests are written in Java using Maven. (Why not node.js-based tests? Because our testing dept. has invested time in creating a Java-based REST-testing framework.)
The build should fail if the node-based unit tests fail or if the java tests fail.
Our Jenkins box is run by a support team elsewhere in the company; our builds execute on a Linux slave.
Current Attempt
We've got something that kind-of works right now, but it's unreliable. We use 3 build steps:
The first build step is an Execute Shell step with the following commands:
npm install
npm test
node server.js ./test-config.json &
Second we do a Invoke Maven 3 step that points to the test pom.xml.
And third we run Invoke Standalone Sonar Analysis to do static code analysis.
This mostly works, but we depend on Jenkins' ProcessTreeKiller to stop the services once the job completes. We always get the warnings stating: Process leaked file descriptors. See
http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+buildfor
more information
Unfortunately, we've had cases where the service is terminated too soon (before the tests complete) or where the service doesn't get terminated at all (causing subsequent builds to fail because the port is already in use).
So we need something more reliable.
Failed Attempt
We tried setting up a single shell script which handled starting the service, running maven, killing the service, then outputting an exit code. But this didn't work out because the mvn command wasn't available on the command-line. Our Jenkins has multiple maven versions available (and jdks too) and I don't know where they live on the slaves or how to get at them without using the Invoke Maven 3 build step.
Ideas
We've toyed around with some ideas to solve this problem, but are hoping to get some guidance from others that may have solved similar problems with Jenkins.
Have the service self-terminate after some period of time. Problem is figuring out how long to let them run.
Add a build step to kill the services after we're done. Problem is that if the maven execution fails, subsequent steps won't run. (And if we tell maven to ignore test failures, then the build doesn't show as broken if they fail.)
Try killing any existing service process as the first and last steps of the build. Problem is that other teams also use these Jenkins slaves so we need to make sure that the service is terminated when we're done with our build.
Start and stop the node.js services via Maven doing something like this blog suggests. Problem is that we don't know if Jenkins will identify the spawned background task as a "leaked file descriptor" and kill it before we're done testing.
It would be nice if Jenkins had a "Post-build action" that let you run a clean-up script. Or if it had a "Execute background process" build step which would kill the background items at the end of the build. But I can't find anything like that.
Has anyone managed to get Jenkins to do anything remotely like this?
Some brainstorming:
You can turn off Jenkins ProcessTreeKiller, either globally or per invocation. I am not sure why that is not an option for you.
In response to #2, several options:
Post-build actions get executed regardless if build steps had failed or not. This would be a great way to trigger a "service cleanup" task that will run regardless of the build state.
You can setup any build step as post-build action, using Any Build Step plugin, or you can use Post Build Tasks plugin, the latter even gives options to define triggering criteria.
You can change the build state, based on RegEx criteria using Text-finder plugin
You can setup Conditional Build Steps. The "condition" could even be a result of some script execution
I'm new to Jenkins/Hudson but I didn't find a plugin which provides the functionality I am looking for.
I want to make the build process of my web application dependent on multiple function tests I already implemented in JMeter and soapUI. So after the project is built, the tests should start. If they fail (to a certain amount), the whole build should fail (and not only the job containing the tests).
As I have read, post-build actions and JMeter/soapUI tests are not a problem. The only missing things seems to be the connection to the success of the whole build. Is there a plugin or a workaround for my requirements?
Regards
You need the Performance Plugin:
Add a JMeter Report and define the path to your jtl files.
To mark the build to status as failure you need to specify the Failed threshold.
Example:
If you specify a threshold of 20%: If 20% or more of your jmeter samples fail, the jenkins job is marked as failure.
I've a simple Jenkins job where i runt python script to run a bunch of tests. I see the build as UNSTABLE even i see no obvious errors in the Jenkins job as well as no tests failing.
Whats i'm running is python
I'm not using any external test framework like nose. Its just a python script.
"Unstable" is the result Jenkins assigned when tests are failing. The only other way to get "Unstable" result is through the use of some post-build plugins. If you don't have any other plugins that are setting the build as unstable, then you have to take a closer look at all the tests.
If you paste the console output here, that would help as well