How to start a job if the current task is not completed?
In my task, I need to run the same job if its current build fails. I don't need a trigger if the build succeeded.
Are there any plugins or any other method to accomplish this task?
You can use Load Additional Plugin for this:
my_project
will only run if the build fails.
Note : if you want to run the same job, you must understand that this is a chance to have an infinitive loop. If the build always fails, it will run over and over ...
The best solution is to use the Naginator plugin .
If the build fails, it will be rescheduled after the time you specified. You can choose how many times to repeat the task. For each consecutive failed build, you can extend the timeout period.
Jenkins Naginator plugin
Jenkins Naginator Plugin can be used to automatically reconfigure a build after a failure.
This becomes very useful in scenarios where a build fails due to unavoidable reasons such as database connection is lost, file system is unavailable, etc.
Configuration
The rescheduling configuration is available as a post-build action. There are several configurations to make the right choice based on the expected (unavoidable) reason for the build failure.
More details on config here with screenshot.