In Jenkins, if next trigger build is in pending state then how to abort running build and start running next pending build? -


in jenkins, if 1 build running , next 1 in pending state should running 1 should aborted , next pending 1 should start running , on.

i have few projects , each project has few jobs in it, tried save build_number env variable in 1 text file (build_number.txt) , take number abort previous triggered build making build_number.txt file each job not looking efficient , have create many build_number files each job every project.

can please suggest me better approach

thanks

based on comments, if sending many emails actual problem, can use poll scm poll once in 15 minutes or so, or specify quiet time job. ensure build taken once in 15 minutes. users should locally test before commit. if jenkins used verifying commits don't see wrong in sending email if build fails. after all, supposed know that, no matter if fixed in later update intentionally or unintentionally.

but if still want abort running job if there updates, can try following. lets call job aborted job a

  1. create job listens on updates same of job needs aborted
  2. add build step execute groovy script
  3. in groovy script use jenkins apis check if job running. if yes, again use apis abort job.

jenkins apis available here


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -