I have a jenkins build with three ant tasks. If the first ant task fails, jenkins continues with the next ant task. How can I get jenkins to fail the build and stop when an ant task fails?
I'm assuming you're missing a "failonerror=true" attribute within your ant task. A lot of sub tasks default this value to false. (e.g. Java Task for example).
Could you post your entire ant script if that's not the case?
Related
I have separated my build tasks in several jobs. The following is a simplified structure.
The basic jobs are:
compile
quick-tests
full-tests-part-1
full-tests-part-2
Additional jobs are:
full-tests
full-build
Each job is configured to accept a workspace parameter to allow all jobs to be executed on the same code (workspace). This is passed from any calling job. Besides, all jobs are running on a slave node.
Job full-tests is configured to bundle the "full tests". Therefore it uses the build step Trigger/call builds on other projects with projects full-tests-part-1, full-tests-part-2.
Job full-build is configured to bundle the build pipeline. Therefore it uses the build step Trigger/call builds on other projects with projects compile, full-tests.
Job compile checks out the Git repository and compiles the code. Afterwards it starts the quick tests. Therfore it uses the post build action Trigger parametrized build on other projects with project quick-tests.
All compilation and test runs are triggered by Ant scripts.
When I trigger the full-build job, the following job sequence results:
full-build
compile (triggers quick-tests)
full-tests
full-tests-part-1
full-tests-part-2
quick-tests
The problem is, that the "full tests" are failing, whereas compile and quick-tests succeed. Both, the full and the quick tests, use the same build.xml in the same workspace, but the "full tests" complains.
Quick tests:
Buildfile: J:\jenkins-slave\workspace\full-build\272\project-path\build.xml
Full tests:
ERROR: Unable to find build script at J:\jenkins-slave\workspace\full-build\272\project-path\build.xml
Does anyone know whether there is a difference in "seeing" the workspace files depending on whether the job is part of the build (triggered as build step) or not (triggered as post build action).
If anything is unclear, please let me know.
My jenkins job "Build" configuration has
3 Execute shell - build tasks
2 Post build action
Is there any way to get the runtime of each buildtask and postbuild action ?
Not directly, which is why:
I use a Jenkins plugin timestamper to add the timestamps in the logs, giving me the opportunity to extract each task duration.
there are plugins like additional-metrics-plugin or build-metrics which collect job duration (but not necessarily task or post-build task duration): they could be good starting point for making a custom plugin which would collect what you need.
https://docs.gradle.org/current/userguide/command_line_interface.html#_executing_multiple_tasks
I know gradle allows to execute multi-tasks in order.
In my case, gradle stopped when it finishes the first tasks
my command is like:
gradle taskA taskB taksC
It just skip everything after taskA.
My gradle is 4.1
I'm trying to run my tests in Jenkins with Gradle. I have a gradle task called 'test' and I specify which tests to run with --tests
Using the Jenkins Gradle plugin, I've specified the Switches (--tests ) and Tasks ('test') but when the build actually runs it puts the --tests stuff before the tasks which doesn't work at all. I need the task to come first on the commandline before the switches otherwise it doesn't work. What can I do here?
If you add --tests to Tasks in the right order it should work.
I.e. try adding
test --tests <test include expression>
as Tasks.
Switches is just for convenience - in the end everything will end up as the argument list of the gradle executable.
After the build is passed for source code, some .jar files are created.
Those jar files have to be put in specific path before triggering relevant testcases in Jenkins.
In a short,
How to configure/set up the test cases after the successful build and before triggering them in Jenkins?
Have 1 job to build your code.
Add a post exec command to this job to move the jar files to the correct path
After this build job is finished have it trigger a second job that does only the tests.